summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2001-01-26 18:05:48 +0000
committerNiklas Nebel <nn@openoffice.org>2001-01-26 18:05:48 +0000
commit21a1c59e4cc997038a76ee4d6c73999fc9f9aa22 (patch)
tree2c18c46174984d11a1bf594130b561579c84a737 /connectivity
parent22de1527a5b839cbff6300495c658562e4115fab (diff)
database driver for spreadsheet documents
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/calc/CCatalog.cxx114
-rw-r--r--connectivity/source/drivers/calc/CColumns.cxx105
-rw-r--r--connectivity/source/drivers/calc/CConnection.cxx257
-rw-r--r--connectivity/source/drivers/calc/CDatabaseMetaData.cxx531
-rw-r--r--connectivity/source/drivers/calc/CDriver.cxx130
-rw-r--r--connectivity/source/drivers/calc/CPreparedStatement.cxx78
-rw-r--r--connectivity/source/drivers/calc/CResultSet.cxx230
-rw-r--r--connectivity/source/drivers/calc/CStatement.cxx78
-rw-r--r--connectivity/source/drivers/calc/CTable.cxx762
-rw-r--r--connectivity/source/drivers/calc/CTables.cxx198
-rw-r--r--connectivity/source/drivers/calc/Cservices.cxx211
-rw-r--r--connectivity/source/drivers/calc/calc.map8
-rw-r--r--connectivity/source/drivers/calc/exports.dxp3
-rw-r--r--connectivity/source/drivers/calc/makefile.mk154
14 files changed, 2859 insertions, 0 deletions
diff --git a/connectivity/source/drivers/calc/CCatalog.cxx b/connectivity/source/drivers/calc/CCatalog.cxx
new file mode 100644
index 000000000000..1fa2c096689f
--- /dev/null
+++ b/connectivity/source/drivers/calc/CCatalog.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * $RCSfile: CCatalog.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _CONNECTIVITY_CALC_CATALOG_HXX_
+#include "calc/CCatalog.hxx"
+#endif
+
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#include "calc/CConnection.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_TABLES_HXX_
+#include "calc/CTables.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+
+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::calc;
+// -------------------------------------------------------------------------
+OCalcCatalog::OCalcCatalog(OCalcConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ refreshTables();
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+void OCalcCatalog::refreshTables()
+{
+ ::std::vector< ::rtl::OUString> aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ delete m_pTables;
+ m_pTables = new OCalcTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+
+
diff --git a/connectivity/source/drivers/calc/CColumns.cxx b/connectivity/source/drivers/calc/CColumns.cxx
new file mode 100644
index 000000000000..867b66abecad
--- /dev/null
+++ b/connectivity/source/drivers/calc/CColumns.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: CColumns.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_COLUMNS_HXX_
+#include "calc/CColumns.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_TABLE_HXX_
+#include "calc/CTable.hxx"
+#endif
+#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
+#include "connectivity/sdbcx/VColumn.hxx"
+#endif
+
+using namespace connectivity::calc;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+Reference< XNamed > OCalcColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ OCalcTable* pTable = (OCalcTable*)m_pTable;
+
+ // Reference< XFastPropertySet> xCol(pTable->getColumns()[_rName],UNO_QUERY);
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+
+ Reference< XNamed > xRet(*find(aCols->begin(),aCols->end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())),UNO_QUERY);
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OCalcColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OCalcColumns::createEmptyObject()
+{
+ sdbcx::OColumn* pRet = new sdbcx::OColumn(isCaseSensitive());
+ Reference< XPropertySet > xRet = pRet;
+ return xRet;
+}
+
diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx
new file mode 100644
index 000000000000..63e3ef2b6678
--- /dev/null
+++ b/connectivity/source/drivers/calc/CConnection.cxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * $RCSfile: CConnection.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#include "calc/CConnection.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_DATABASEMETADATA_HXX_
+#include "calc/CDatabaseMetaData.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_CATALOG_HXX_
+#include "calc/CCatalog.hxx"
+#endif
+#ifndef _CONNECTIVITY_RESOURCE_HRC_
+#include "Resource.hrc"
+#endif
+#ifndef _CONNECTIVITY_MODULECONTEXT_HXX_
+#include "ModuleContext.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_ODRIVER_HXX_
+#include "calc/CDriver.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#endif
+#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _CONNECTIVITY_CALC_PREPAREDSTATEMENT_HXX_
+#include "calc/CPreparedStatement.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_STATEMENT_HXX_
+#include "calc/CStatement.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <svtools/pathoptions.hxx>
+#endif
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+
+typedef connectivity::file::OConnection OConnection_B;
+
+//------------------------------------------------------------------------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::sheet;
+
+// --------------------------------------------------------------------------------
+
+OCalcConnection::OCalcConnection(ODriver* _pDriver) : OConnection(_pDriver)
+{
+ // m_aFilenameExtension is not used
+}
+
+OCalcConnection::~OCalcConnection()
+{
+}
+
+void OCalcConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
+ throw(SQLException)
+{
+ // open file
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1));
+
+ String aFileName = aDSN;
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ {
+ SvtPathOptions aPathOptions;
+ aFileName = aPathOptions.SubstituteVariable(aFileName);
+ }
+ aURL.SetSmartURL(aFileName);
+ aFileName = aURL.GetMainURL();
+
+ Reference< XComponentLoader > xDesktop( getDriver()->getFactory()->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY );
+ if (!xDesktop.is())
+ {
+ OSL_ASSERT("no desktop");
+ throw SQLException();
+ }
+
+ // open read-only as long as updating isn't implemented
+
+ Sequence<PropertyValue> aArgs(2);
+ aArgs[0].Name = ::rtl::OUString::createFromAscii("Hidden");
+ aArgs[0].Value <<= (sal_Bool) sal_True;
+ aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly");
+ aArgs[1].Value <<= (sal_Bool) sal_True;
+
+ Reference<XComponent> xComponent = xDesktop->loadComponentFromURL(
+ aFileName, ::rtl::OUString::createFromAscii("_blank"), 0, aArgs );
+ m_xDoc = Reference<XSpreadsheetDocument>( xComponent, UNO_QUERY );
+
+ // file::OConnection::construct (reads the directory) is not called
+}
+
+void OCalcConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ::comphelper::disposeComponent( m_xDoc );
+
+ OConnection::disposing();
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+
+IMPLEMENT_SERVICE_INFO(OCalcConnection, "com.sun.star.sdbc.drivers.calc.Connection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+
+Reference< XDatabaseMetaData > SAL_CALL OCalcConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OConnection_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OCalcDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+
+//------------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< XTablesSupplier > OCalcConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!m_xCatalog.get().is())
+ {
+ OCalcCatalog *pCat = new OCalcCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XStatement > SAL_CALL OCalcConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OConnection_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ Reference< XStatement > xReturn = new OCalcStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareStatement( const ::rtl::OUString& sql )
+ throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OConnection_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ OCalcPreparedStatement* pStmt = new OCalcPreparedStatement(this,m_aTypeInfo);
+ Reference< XPreparedStatement > xHoldAlive = pStmt;
+ pStmt->construct(sql);
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareCall( const ::rtl::OUString& sql )
+ throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OConnection_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+ return NULL;
+}
+
+
diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
new file mode 100644
index 000000000000..40c8ed8a400a
--- /dev/null
+++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
@@ -0,0 +1,531 @@
+/*************************************************************************
+ *
+ * $RCSfile: CDatabaseMetaData.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _CONNECTIVITY_CALC_OCALCDATABASEMETADATA_HXX_
+#include "calc/CDatabaseMetaData.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#include "calc/CConnection.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPropertySet_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#endif
+#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_
+#include "file/FDatabaseMetaDataResultSet.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#define CONNECTIVITY_PROPERTY_NAME_SPACE calc
+#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
+#include "propertyids.hxx"
+#endif
+
+using namespace connectivity::calc;
+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;
+using namespace ::com::sun::star::sheet;
+
+// -------------------------------------------------------------------------
+
+OCalcDatabaseMetaData::OCalcDatabaseMetaData(OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+}
+
+// -------------------------------------------------------------------------
+
+OCalcDatabaseMetaData::~OCalcDatabaseMetaData()
+{
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setTypeInfoMap();
+ ORows aRows;
+ ORow aRow;
+
+ aRow.push_back(Any());
+ aRow.push_back(makeAny(::rtl::OUString::createFromAscii("VARCHAR")));
+ aRow.push_back(makeAny(DataType::VARCHAR));
+ aRow.push_back(makeAny((sal_Int32)65535));
+ aRow.push_back(makeAny(::rtl::OUString::createFromAscii("'")));
+ aRow.push_back(makeAny(::rtl::OUString::createFromAscii("'")));
+ aRow.push_back(Any());
+ aRow.push_back(makeAny((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(makeAny((sal_Int32)1));
+ aRow.push_back(makeAny((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(makeAny((sal_Int32)1));
+ aRow.push_back(makeAny((sal_Int32)0));
+ aRow.push_back(makeAny((sal_Int32)0));
+ aRow.push_back(Any());
+ aRow.push_back(makeAny((sal_Int32)0));
+ aRow.push_back(makeAny((sal_Int32)0));
+ aRow.push_back(Any());
+ aRow.push_back(Any());
+ aRow.push_back(makeAny((sal_Int32)10));
+ aRows.push_back(aRow);
+
+ aRow[1] = makeAny(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = makeAny(DataType::DECIMAL);
+ aRow[3] = makeAny((sal_Int32)0);
+ aRow[9] = makeAny(ColumnSearch::BASIC);
+ aRow[15] = makeAny((sal_Int32)0);
+ aRows.push_back(aRow);
+
+ aRow[1] = makeAny(::rtl::OUString::createFromAscii("BOOL"));
+ aRow[2] = makeAny(DataType::BIT);
+ aRow[3] = makeAny((sal_Int32)20);
+ aRow[9] = makeAny(ColumnSearch::BASIC);
+ aRow[15] = makeAny((sal_Int32)15);
+ aRows.push_back(aRow);
+
+ aRow[1] = makeAny(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = makeAny(DataType::DATE);
+ aRow[3] = makeAny((sal_Int32)0);
+ aRow[9] = makeAny(ColumnSearch::BASIC);
+ aRow[15] = makeAny((sal_Int32)0);
+ aRows.push_back(aRow);
+
+ aRow[1] = makeAny(::rtl::OUString::createFromAscii("TIME"));
+ aRow[2] = makeAny(DataType::TIME);
+ aRow[3] = makeAny((sal_Int32)0);
+ aRow[9] = makeAny(ColumnSearch::BASIC);
+ aRow[15] = makeAny((sal_Int32)0);
+ aRows.push_back(aRow);
+
+ aRow[1] = makeAny(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = makeAny(DataType::TIMESTAMP);
+ aRow[3] = makeAny((sal_Int32)0);
+ aRow[9] = makeAny(ColumnSearch::BASIC);
+ aRow[15] = makeAny((sal_Int32)0);
+ aRows.push_back(aRow);
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setColumnPrivilegesMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ORows aRows;
+ ORow aRow(19);
+ aRow[10] <<= (sal_Int32)10;
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabBegin = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength();
+ for(;pTabBegin != pTabEnd;++pTabBegin)
+ {
+ if(match(tableNamePattern,*pTabBegin,'\0'))
+ {
+ Reference< XColumnsSupplier> xTable;
+ xNames->getByName(*pTabBegin) >>= xTable;
+ OSL_ENSHURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!");
+ aRow[3] <<= *pTabBegin;
+
+ Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i)
+ {
+ if(match(columnNamePattern,*pBegin,'\0'))
+ {
+ aRow[4] <<= *pBegin;
+
+ xColumns->getByName(*pBegin) >>= xColumn;
+ OSL_ENSHURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = xColumn->getPropertyValue(PROPERTY_TYPE);
+ aRow[6] = xColumn->getPropertyValue(PROPERTY_TYPENAME);
+ aRow[7] = xColumn->getPropertyValue(PROPERTY_PRECISION);
+ // aRow[8] = xColumn->getPropertyValue(PROPERTY_TYPENAME);
+ aRow[9] = xColumn->getPropertyValue(PROPERTY_SCALE);
+ aRow[11] = xColumn->getPropertyValue(PROPERTY_ISNULLABLE);
+ // aRow[12] = xColumn->getPropertyValue(PROPERTY_TYPENAME);
+ aRow[13] = xColumn->getPropertyValue(PROPERTY_DEFAULTVALUE);
+ // aRow[14] = xColumn->getPropertyValue(PROPERTY_TYPENAME);
+ // aRow[15] = xColumn->getPropertyValue(PROPERTY_TYPENAME);
+ switch(getINT32(aRow[5]))
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] <<= (sal_Int32)254;
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] <<= (sal_Int32)65535;
+ break;
+ default:
+ aRow[16] <<= (sal_Int32)0;
+ }
+ aRow[17] <<= i;
+ switch(getINT32(aRow[11]))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] <<= ::rtl::OUString::createFromAscii("NO");
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] <<= ::rtl::OUString::createFromAscii("YES");
+ break;
+ default:
+ aRow[18] <<= ::rtl::OUString();
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setColumnsMap();
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getVersionColumns(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setVersionColumnsMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setExportedKeysMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setImportedKeysMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setPrimaryKeysMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getIndexInfo(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ORows aRows;
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setIndexInfoMap();
+ pResult->setRows(aRows);
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getBestRowIdentifier(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
+ sal_Bool nullable ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setBestRowIdentifierMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getCrossReference(
+ const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setCrossReferenceMap();
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OCalcDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return ::rtl::OUString::createFromAscii("sdbc:calc:");
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return STRING_MAXLEN;
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return 256;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types )
+ throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
+ Reference< XResultSet > xRef = pResult;
+ pResult->setTablesMap();
+
+ // check if any type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ ::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;
+
+ // get the sheet names from the document
+
+ Reference<XSpreadsheetDocument> xDoc = ((OCalcConnection*)m_pConnection)->getDoc();
+ if ( !xDoc.is() )
+ throw SQLException();
+ Reference<XSpreadsheets> xSheets = xDoc->getSheets();
+ if ( !xSheets.is() )
+ throw SQLException();
+ Sequence< ::rtl::OUString > aSheetNames = xSheets->getElementNames();
+
+ ORows aRows;
+ sal_Int32 nSheetCount = aSheetNames.getLength();
+ for (sal_Int32 nSheet=0; nSheet<nSheetCount; nSheet++)
+ {
+ //! leave out hidden or empty sheets?
+
+ ::rtl::OUString aName = aSheetNames[nSheet];
+
+ ORow aRow(3);
+ aRow.push_back(makeAny(aName));
+ aRow.push_back(makeAny(aTable));
+ aRow.push_back(Any());
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+
diff --git a/connectivity/source/drivers/calc/CDriver.cxx b/connectivity/source/drivers/calc/CDriver.cxx
new file mode 100644
index 000000000000..3bb046934893
--- /dev/null
+++ b/connectivity/source/drivers/calc/CDriver.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * $RCSfile: CDriver.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_DRIVER_HXX_
+#include "calc/CDriver.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#include "calc/CConnection.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+
+//------------------------------------------------------------------------------
+// static ServiceInfo
+
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdbc.driver.calc.Driver");
+}
+
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// service names from file::OFileDriver
+
+//------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url,
+ const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ OCalcConnection* pCon = new OCalcConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:calc:"),10))
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+
diff --git a/connectivity/source/drivers/calc/CPreparedStatement.cxx b/connectivity/source/drivers/calc/CPreparedStatement.cxx
new file mode 100644
index 000000000000..b16017ae9f61
--- /dev/null
+++ b/connectivity/source/drivers/calc/CPreparedStatement.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * $RCSfile: CPreparedStatement.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_PREPAREDSTATEMENT_HXX_
+#include "calc/CPreparedStatement.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_RESULTSET_HXX_
+#include "calc/CResultSet.hxx"
+#endif
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+// -------------------------------------------------------------------------
+OResultSet* OCalcPreparedStatement::createResultSet()
+{
+ return new OCalcResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OCalcPreparedStatement,"com.sun.star.sdbc.driver.calc.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
diff --git a/connectivity/source/drivers/calc/CResultSet.cxx b/connectivity/source/drivers/calc/CResultSet.cxx
new file mode 100644
index 000000000000..7c913ce473e7
--- /dev/null
+++ b/connectivity/source/drivers/calc/CResultSet.cxx
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * $RCSfile: CResultSet.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#endif
+#ifndef _CONNECTIVITY_CALC_RESULTSET_HXX_
+#include "calc/CResultSet.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#define CONNECTIVITY_PROPERTY_NAME_SPACE calc
+#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
+#include "propertyids.hxx"
+#endif
+// define the properties of this lib
+// this file includes the properties for this dll
+namespace connectivity
+{
+ namespace calc
+ {
+#ifndef CONNECTIVITY_USTRINGDESCRIPTION_IMPL_HXX
+#include "UStringDescription_Impl.hxx"
+#endif
+ }
+}
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// using namespace com::sun::star::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.calc.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ if (pSupported->equals(_rServiceName))
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OResultSet::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OCalcResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException)
+{
+ return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ return makeAny((sal_Int32)(*m_aRow)[0]);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(OFileTable::FILE_BOOKMARK,connectivity::getINT32(bookmark),sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(OFileTable::FILE_BOOKMARK,connectivity::getINT32(bookmark)+rows,sal_True);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& first, const Any& second ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ return (first == second) ? 0 : 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ return connectivity::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (OResultSet_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+sal_Bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
+{
+ // Calc table has no index
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper()
+{
+ return *OCalcResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/calc/CStatement.cxx b/connectivity/source/drivers/calc/CStatement.cxx
new file mode 100644
index 000000000000..c0b134be532f
--- /dev/null
+++ b/connectivity/source/drivers/calc/CStatement.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * $RCSfile: CStatement.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_STATEMENT_HXX_
+#include "calc/CStatement.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_RESULTSET_HXX_
+#include "calc/CResultSet.hxx"
+#endif
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+// -------------------------------------------------------------------------
+OResultSet* OCalcStatement::createResultSet()
+{
+ return new OCalcResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OCalcStatement,"com.sun.star.sdbc.driver.calc.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx
new file mode 100644
index 000000000000..8e903b68665e
--- /dev/null
+++ b/connectivity/source/drivers/calc/CTable.cxx
@@ -0,0 +1,762 @@
+/*************************************************************************
+ *
+ * $RCSfile: CTable.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_TABLE_HXX_
+#include "calc/CTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEET_HPP_
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_XCELLRANGEADDRESSABLE_HPP_
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _SV_CONVERTER_HXX_
+#include <svtools/converter.hxx>
+#endif
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#include "calc/CConnection.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_COLUMNS_HXX_
+#include "calc/CColumns.hxx"
+#endif
+#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
+#include "connectivity/sdbcx/VColumn.hxx"
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+#ifndef _CONFIG_HXX //autogen
+#include <vcl/config.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _CONNECTIVITY_DATECONVERSION_HXX_
+#include "connectivity/DateConversion.hxx"
+#endif
+#ifndef _INTN_HXX //autogen
+#include <tools/intn.hxx>
+#endif
+#ifndef _ZFORLIST_HXX //autogen
+#include <svtools/zforlist.hxx>
+#endif
+#ifndef _SOLMATH_HXX //autogen wg. SolarMath
+#include <tools/solmath.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#define CONNECTIVITY_PROPERTY_NAME_SPACE calc
+#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
+#include "propertyids.hxx"
+#endif
+#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
+#include <unotools/ucbstreamhelper.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _DBHELPER_DBCONVERSION_HXX_
+#include <connectivity/dbconversion.hxx>
+#endif
+
+using namespace connectivity;
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::ucb;
+using namespace ::cppu;
+using namespace ::dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sheet;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::util;
+
+// -------------------------------------------------------------------------
+
+sal_Int32 lcl_ColumnCount( const Reference<XSpreadsheet>& xSheet )
+{
+ Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
+ Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
+ if ( !xRange.is() )
+ return 0;
+
+ xCursor->collapseToSize( 1, 1 ); // single (first) cell
+ xCursor->collapseToCurrentRegion(); // contiguous data area
+
+ CellRangeAddress aRangeAddr = xRange->getRangeAddress();
+ return aRangeAddr.EndColumn + 1;
+}
+
+sal_Int32 lcl_RowCount( const Reference<XSpreadsheet>& xSheet )
+{
+ //! detect missing header row
+
+ Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
+ Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
+ if ( !xRange.is() )
+ return 0;
+
+ xCursor->collapseToSize( 1, 1 ); // single (first) cell
+ xCursor->collapseToCurrentRegion(); // contiguous data area
+
+ CellRangeAddress aRangeAddr = xRange->getRangeAddress();
+ return aRangeAddr.EndRow; // first row (headers) is not counted
+}
+
+void lcl_GetColumnInfo( const Reference<XSpreadsheet>& xSheet, const Reference<XNumberFormats>& xFormats,
+ sal_Int32 nDocColumn,
+ ::rtl::OUString& rName, sal_Int32& rDataType, sal_Bool& rCurrency )
+{
+ // nDocColumn is 0-based
+
+ //! detect missing header row
+ //! avoid duplicate field names
+
+ // get column name from first row
+
+ Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, 0 );
+ Reference<XText> xText( xCell, UNO_QUERY );
+ if ( xText.is() )
+ rName = xText->getString();
+
+ // get column type from first data row
+
+ sal_Int32 nDataRow = 1; //! detect missing header row
+ xCell = xSheet->getCellByPosition( nDocColumn, nDataRow );
+ Reference<XPropertySet> xProp( xCell, UNO_QUERY );
+ if ( xProp.is() )
+ {
+ rCurrency = sal_False; // set to true for currency below
+
+ CellContentType eCellType = xCell->getType();
+ if ( eCellType == CellContentType_FORMULA )
+ {
+ //! use FormulaResultType property
+ }
+
+ if ( eCellType == CellContentType_TEXT )
+ rDataType = DataType::VARCHAR;
+ else if ( eCellType == CellContentType_VALUE )
+ {
+ // get number format to distinguish between different types
+
+ sal_Int16 nNumType = NumberFormat::NUMBER;
+ try
+ {
+ Any aNumAny = xProp->getPropertyValue( ::rtl::OUString::createFromAscii("NumberFormat") );
+ sal_Int32 nKey;
+ if ( aNumAny >>= nKey )
+ {
+ Reference<XPropertySet> xFormat = xFormats->getByKey( nKey );
+ if ( xFormat.is() )
+ {
+ Any aTypeAny = xFormat->getPropertyValue( ::rtl::OUString::createFromAscii("Type") );
+ aTypeAny >>= nNumType;
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+
+ if ( nNumType & NumberFormat::NUMBER )
+ rDataType = DataType::DECIMAL;
+ else if ( nNumType & NumberFormat::CURRENCY )
+ {
+ rCurrency = sal_True;
+ rDataType = DataType::DECIMAL;
+ }
+ else if ( ( nNumType & NumberFormat::DATETIME ) == NumberFormat::DATETIME )
+ {
+ // NumberFormat::DATETIME is DATE | TIME
+ rDataType = DataType::TIMESTAMP;
+ }
+ else if ( nNumType & NumberFormat::DATE )
+ rDataType = DataType::DATE;
+ else if ( nNumType & NumberFormat::TIME )
+ rDataType = DataType::TIME;
+ else if ( nNumType & NumberFormat::LOGICAL )
+ rDataType = DataType::BIT;
+ else
+ rDataType = DataType::DECIMAL;
+ }
+ else
+ {
+ //! find first non-empty row
+ rDataType = DataType::VARCHAR;
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+
+void lcl_SetValue( file::ORowSetValue& rValue, const Reference<XSpreadsheet>& xSheet,
+ const ::Date& rNullDate,
+ sal_Int32 nDBRow, sal_Int32 nDBColumn, sal_Int32 nType )
+{
+ sal_Int32 nDocColumn = nDBColumn - 1; // database counts from 1
+ sal_Int32 nDocRow = nDBRow; //! detect missing header row
+
+ Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow );
+ if ( xCell.is() )
+ {
+ switch (nType)
+ {
+ case DataType::VARCHAR:
+ {
+ Reference<XText> xText( xCell, UNO_QUERY );
+ if ( xText.is() )
+ {
+ ::rtl::OUString sVal = xText->getString();
+ rValue = sVal;
+ }
+ }
+ break;
+ case DataType::DECIMAL:
+ rValue = xCell->getValue(); // double
+ break;
+ case DataType::BIT:
+ rValue = (sal_Bool)( xCell->getValue() != 0.0 );
+ break;
+ case DataType::DATE:
+ {
+ ::Date aDate( rNullDate );
+ aDate += (long)SolarMath::ApproxFloor( xCell->getValue() );
+ ::com::sun::star::util::Date aDateStruct( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
+ rValue = aDateStruct;
+ }
+ break;
+ case DataType::TIME:
+ {
+ double fCellVal = xCell->getValue();
+ double fTime = fCellVal - SolarMath::ApproxFloor( fCellVal );
+ long nIntTime = (long)SolarMath::Round( fTime * 8640000.0 );
+ if ( nIntTime == 8640000 )
+ nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
+ ::com::sun::star::util::Time aTime;
+ aTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
+ nIntTime /= 100;
+ aTime.Seconds = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ aTime.Minutes = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ OSL_ENSHURE( nIntTime < 24, "error in time calculation" );
+ aTime.Hours = (sal_uInt16) nIntTime;
+ rValue = aTime;
+ }
+ break;
+ case DataType::TIMESTAMP:
+ {
+ double fCellVal = xCell->getValue();
+ double fDays = SolarMath::ApproxFloor( fCellVal );
+ double fTime = fCellVal - fDays;
+ long nIntDays = (long)fDays;
+ long nIntTime = (long)SolarMath::Round( fTime * 8640000.0 );
+ if ( nIntTime == 8640000 )
+ {
+ nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
+ ++nIntDays; // (next day)
+ }
+
+ ::com::sun::star::util::DateTime aDateTime;
+
+ aDateTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
+ nIntTime /= 100;
+ aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ OSL_ENSHURE( nIntTime < 24, "error in time calculation" );
+ aDateTime.Hours = (sal_uInt16) nIntTime;
+
+ ::Date aDate( rNullDate );
+ aDate += nIntDays;
+ aDateTime.Day = aDate.GetDay();
+ aDateTime.Month = aDate.GetMonth();
+ aDateTime.Year = aDate.GetYear();
+
+ rValue = aDateTime;
+ }
+ break;
+ }
+ }
+
+// rValue.setTypeKind(nType);
+}
+
+// -------------------------------------------------------------------------
+
+void OCalcTable::fillColumns()
+{
+ if ( !m_xSheet.is() )
+ throw SQLException();
+
+ sal_Int32 nFieldCount = lcl_ColumnCount( m_xSheet );
+
+ String aStrFieldName;
+ aStrFieldName.AssignAscii("Column");
+ ::rtl::OUString aTypeName;
+
+ for (sal_Int32 i = 0; i < nFieldCount; i++)
+ {
+ ::rtl::OUString aColumnName;
+ sal_Int32 eType = DataType::OTHER;
+ sal_Bool bCurrency = sal_False;
+
+ lcl_GetColumnInfo( m_xSheet, m_xFormats, i, aColumnName, eType, bCurrency );
+
+ sal_Int32 nPrecision = 0; //! ...
+ sal_Int32 nDecimals = 0; //! ...
+
+ switch ( eType )
+ {
+ case DataType::VARCHAR:
+ aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
+ break;
+ case DataType::DECIMAL:
+ aTypeName = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::BIT:
+ aTypeName = ::rtl::OUString::createFromAscii("BOOL");
+ break;
+ case DataType::DATE:
+ aTypeName = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case DataType::TIME:
+ aTypeName = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ case DataType::TIMESTAMP:
+ aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ default:
+ OSL_ASSERT("missing type name");
+ aTypeName = ::rtl::OUString();
+ }
+
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn( aColumnName, aTypeName, ::rtl::OUString(),
+ ColumnValue::NULLABLE, nPrecision, nDecimals,
+ eType, sal_False, sal_False, bCurrency,
+ getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers() );
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nDecimals);
+ }
+}
+
+// -------------------------------------------------------------------------
+OCalcTable::OCalcTable(OCalcConnection* _pConnection)
+ :OCalcTable_BASE(_pConnection)
+{
+}
+// -------------------------------------------------------------------------
+OCalcTable::OCalcTable(OCalcConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OCalcTable_BASE(_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+{
+ // get sheet object
+
+ Reference<XSpreadsheetDocument> xDoc = _pConnection->getDoc();
+ if (xDoc.is())
+ {
+ Reference<XSpreadsheets> xSheets = xDoc->getSheets();
+ if (xSheets.is())
+ {
+ try
+ {
+ Any aAny = xSheets->getByName( _Name );
+ aAny >>= m_xSheet;
+ }
+ catch (NoSuchElementException&)
+ {
+ }
+ }
+
+ Reference<XNumberFormatsSupplier> xSupp( xDoc, UNO_QUERY );
+ if (xSupp.is())
+ m_xFormats = xSupp->getNumberFormats();
+
+ Reference<XPropertySet> xProp( xDoc, UNO_QUERY );
+ if (xProp.is())
+ {
+ Any aDateAny = xProp->getPropertyValue( ::rtl::OUString::createFromAscii("NullDate") );
+ ::com::sun::star::util::Date aDateStruct;
+ if ( aDateAny >>= aDateStruct )
+ m_aNullDate = ::Date( aDateStruct.Day, aDateStruct.Month, aDateStruct.Year );
+ }
+ }
+
+ //! default if no null date available?
+
+ //! detect missing header row
+
+ fillColumns();
+
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+void OCalcTable::refreshColumns()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::std::vector< ::rtl::OUString> aVector;
+
+ for(OSQLColumns::const_iterator aIter = m_aColumns->begin();aIter != m_aColumns->end();++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ delete m_pColumns;
+ m_pColumns = new OCalcColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OCalcTable::refreshIndexes()
+{
+ // Calc table has no index
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCalcTable::disposing(void)
+{
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+#ifdef DEBUG
+ for(OSQLColumns::const_iterator aIter = m_aColumns->begin();aIter != m_aColumns->end();++aIter)
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProp = *aIter;
+ xProp = NULL;
+ }
+#endif
+ m_aColumns->clear();
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCalcTable::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ Sequence< Type > aRet(aTypes.getLength()-3);
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ sal_Int32 i=0;
+ for(;pBegin != pEnd;++pBegin,++i)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRename>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ {
+ aRet.getArray()[i] = *pBegin;
+ }
+ }
+ aRet.getArray()[i] = ::getCppuType( (const Reference< ::com::sun::star::lang::XUnoTunnel > *)0 );
+
+ return aRet;
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OCalcTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+ if(aRet.hasValue())
+ return aRet;
+
+ return OTable_TYPEDEF::queryInterface(rType);
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OCalcTable::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 OCalcTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return (sal_Int64)this;
+
+ return OCalcTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Int32 OCalcTable::getCurrentLastPos() const
+{
+ //! cache
+ return lcl_RowCount( m_xSheet );
+}
+//------------------------------------------------------------------
+sal_Bool OCalcTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+
+ sal_uInt32 nNumberOfRecords = lcl_RowCount( m_xSheet );
+ sal_uInt32 nTempPos = m_nFilePos;
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case FILE_NEXT:
+ m_nFilePos++;
+ break;
+ case FILE_PRIOR:
+ if (m_nFilePos > 0)
+ m_nFilePos--;
+ break;
+ case FILE_FIRST:
+ m_nFilePos = 1;
+ break;
+ case FILE_LAST:
+ m_nFilePos = nNumberOfRecords;
+ break;
+ case FILE_RELATIVE:
+ m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L
+ : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset);
+ break;
+ case FILE_ABSOLUTE:
+ case FILE_BOOKMARK:
+ m_nFilePos = (sal_uInt32)nOffset;
+ break;
+ }
+
+ if (m_nFilePos > (sal_Int32)nNumberOfRecords)
+ m_nFilePos = (sal_Int32)nNumberOfRecords + 1;
+
+ if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1)
+ goto Error;
+ else
+ {
+ //! read buffer / setup row object etc?
+ }
+ goto End;
+
+Error:
+ switch(eCursorPosition)
+ {
+ case FILE_PRIOR:
+ case FILE_FIRST:
+ m_nFilePos = 0;
+ break;
+ case FILE_LAST:
+ case FILE_NEXT:
+ case FILE_ABSOLUTE:
+ case FILE_RELATIVE:
+ if (nOffset > 0)
+ m_nFilePos = nNumberOfRecords + 1;
+ else if (nOffset < 0)
+ m_nFilePos = 0;
+ break;
+ case FILE_BOOKMARK:
+ m_nFilePos = nTempPos; // vorherige Position
+ }
+ // aStatus.Set(SDB_STAT_NO_DATA_FOUND);
+ return sal_False;
+
+End:
+ nCurPos = m_nFilePos;
+ return sal_True;
+}
+//------------------------------------------------------------------
+sal_Bool OCalcTable::fetchRow( file::OValueRow _rRow, const OSQLColumns & _rCols,
+ sal_Bool _bUseTableDefs, sal_Bool bRetrieveData )
+{
+ // read the bookmark
+
+ BOOL bIsCurRecordDeleted = sal_False;
+ _rRow->setDeleted(bIsCurRecordDeleted);
+ (*_rRow)[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+
+ // fields
+
+ OSQLColumns::const_iterator aIter = _rCols.begin();
+ for (sal_Int32 i = 1; aIter != _rCols.end();++aIter, i++)
+ {
+ Reference< XPropertySet> xColumn = *aIter;
+
+// ::rtl::OUString aName;
+// xColumn->getPropertyValue(PROPERTY_NAME) >>= aName;
+
+ sal_Int32 nType;
+ if(_bUseTableDefs)
+ nType = m_aTypes[i-1];
+ else
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+
+ if ((*_rRow)[i].isBound())
+ lcl_SetValue( (*_rRow)[i], m_xSheet, m_aNullDate, m_nFilePos, i, nType );
+ }
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+void OCalcTable::FileClose()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OCalcTable_BASE::FileClose();
+}
+// -------------------------------------------------------------------------
+BOOL OCalcTable::CreateImpl()
+{
+ return sal_False; // read-only for now
+}
+
+//------------------------------------------------------------------
+BOOL OCalcTable::DropImpl()
+{
+ return sal_False; // read-only for now
+}
+//------------------------------------------------------------------
+BOOL OCalcTable::InsertRow(OValueVector& rRow, BOOL bFlush,const Reference<XIndexAccess>& _xCols)
+{
+ return sal_False; // read-only for now
+}
+
+//------------------------------------------------------------------
+BOOL OCalcTable::UpdateRow(file::OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols)
+{
+ return sal_False; // read-only for now
+}
+
+//------------------------------------------------------------------
+BOOL OCalcTable::DeleteRow(const OSQLColumns& _rCols)
+{
+ return sal_False; // read-only for now
+}
+
+// -------------------------------------------------------------------------
+Reference<XPropertySet> OCalcTable::isUniqueByColumnName(const ::rtl::OUString& _rColName)
+{
+ return Reference<XPropertySet>();
+}
+//------------------------------------------------------------------
+BOOL OCalcTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols)
+{
+ return sal_False; // read-only for now
+}
+//------------------------------------------------------------------
+BOOL OCalcTable::WriteBuffer()
+{
+ return sal_False; // read-only for now
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CTables.cxx b/connectivity/source/drivers/calc/CTables.cxx
new file mode 100644
index 000000000000..03c92d648e07
--- /dev/null
+++ b/connectivity/source/drivers/calc/CTables.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: CTables.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_TABLES_HXX_
+#include "calc/CTables.hxx"
+#endif
+#ifndef _CONNECTIVITY_CALC_TABLE_HXX_
+#include "calc/CTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#endif
+#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_
+#include "file/FCatalog.hxx"
+#endif
+#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
+#include "file/FConnection.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _CONNECTIVITY_CALC_CATALOG_HXX_
+#include "calc/CCatalog.hxx"
+#endif
+#define CONNECTIVITY_PROPERTY_NAME_SPACE calc
+#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
+#include "propertyids.hxx"
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+Reference< XNamed > OCalcTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ OCalcTable* pRet = new OCalcTable((OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+
+ Reference< XNamed > xRet = pRet;
+// if(!pRet->isValid())
+// {
+// ::comphelper::disposeComponent(xRet);
+// throw SQLException(::rtl::OUString::createFromAscii("Invalid DBase file found!"),m_rParent,_rName,1000,Any());
+// }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OCalcTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OCalcCatalog*>(&m_rParent)->refreshTables();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OCalcTables::createEmptyObject()
+{
+ OCalcTable* pRet = new OCalcTable((OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection());
+ Reference< XPropertySet > xRet = pRet;
+ return xRet;
+}
+typedef connectivity::sdbcx::OCollection OCalcTables_BASE_BASE;
+// -------------------------------------------------------------------------
+// XAppend
+void SAL_CALL OCalcTables::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME));
+ ObjectMap::iterator aIter = m_aNameMap.find(aName);
+ if( aIter != m_aNameMap.end())
+ throw ElementExistException(aName,*this);
+
+ Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OCalcTable* pTable = (OCalcTable*)xTunnel->getSomething(OCalcTable::getUnoTunnelImplementationId());
+ if(pTable && pTable->CreateImpl())
+ {
+ OCalcTables_BASE_BASE::appendByDescriptor(Reference< XPropertySet >(createObject(aName),UNO_QUERY));
+ }
+ }
+}
+// -------------------------------------------------------------------------
+// XDrop
+void SAL_CALL OCalcTables::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ ObjectMap::iterator aIter = m_aNameMap.find(elementName);
+ if( aIter == m_aNameMap.end())
+ throw NoSuchElementException(elementName,*this);
+
+ Reference< XUnoTunnel> xTunnel(aIter->second.get(),UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OCalcTable* pTable = (OCalcTable*)xTunnel->getSomething(OCalcTable::getUnoTunnelImplementationId());
+ if(pTable && pTable->DropImpl())
+ OCalcTables_BASE_BASE::dropByName(elementName);
+ }
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCalcTables::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if (index < 0 || index >= getCount())
+ throw IndexOutOfBoundsException();
+
+ dropByName((*m_aElements[index]).first);
+}
+// -------------------------------------------------------------------------
+//------------------------------------------------------------------
+Any SAL_CALL OCalcTables::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ typedef sdbcx::OCollection OTables_BASE;
+ return OTables_BASE::queryInterface(rType);
+}
+
diff --git a/connectivity/source/drivers/calc/Cservices.cxx b/connectivity/source/drivers/calc/Cservices.cxx
new file mode 100644
index 000000000000..e4c257ea4dbd
--- /dev/null
+++ b/connectivity/source/drivers/calc/Cservices.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: Cservices.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_DRIVER_HXX_
+#include "calc/CDriver.hxx"
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+using namespace connectivity::calc;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSHURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **ppEnv
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSHURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/calc/calc.map b/connectivity/source/drivers/calc/calc.map
new file mode 100644
index 000000000000..57d49a9ba463
--- /dev/null
+++ b/connectivity/source/drivers/calc/calc.map
@@ -0,0 +1,8 @@
+CALC_1_0 {
+ global:
+ component_getImplementationEnvironment
+ component_writeInfo
+ component_getFactory
+ local:
+ *;
+};
diff --git a/connectivity/source/drivers/calc/exports.dxp b/connectivity/source/drivers/calc/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/calc/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/calc/makefile.mk b/connectivity/source/drivers/calc/makefile.mk
new file mode 100644
index 000000000000..97d24493a8d4
--- /dev/null
+++ b/connectivity/source/drivers/calc/makefile.mk
@@ -0,0 +1,154 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: nn $ $Date: 2001-01-26 19:05:48 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=calc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+# --- Types -------------------------------------
+
+
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+
+UNOUCROUT=$(OUT)$/inc
+INCPRE+=$(UNOUCROUT)
+
+# --- Types -------------------------------------
+
+UNOTYPES+= \
+ com.sun.star.sdbcx.XRowLocate \
+ com.sun.star.sdbcx.CompareBookmark \
+ com.sun.star.sdbcx.XDeleteRows
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/CResultSet.obj \
+ $(SLO)$/CStatement.obj \
+ $(SLO)$/CPreparedStatement.obj \
+ $(SLO)$/CDatabaseMetaData.obj \
+ $(SLO)$/CCatalog.obj \
+ $(SLO)$/CColumns.obj \
+ $(SLO)$/CTable.obj \
+ $(SLO)$/CTables.obj \
+ $(SLO)$/CConnection.obj \
+ $(SLO)$/Cservices.obj \
+ $(SLO)$/CDriver.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmbcalc.obj
+.ENDIF
+
+SHL1VERSIONMAP= $(TARGET).map
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(UPD)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(OSLLIB) \
+ $(SVLLIB) \
+ $(SVLIB) \
+ $(TOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(COMPHELPERLIB)" == ""
+SHL1STDLIBS+= icomphelp2.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/file.lib
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+