From ab3a8d0d5f8d5389cb6c9968ad42fb358e343b10 Mon Sep 17 00:00:00 2001 From: Release Engineers Date: Fri, 3 Jul 2009 12:24:35 +0000 Subject: CWS-TOOLING: integrate CWS dbaperf2 2009-06-22 11:04:36 +0200 msc r273202 : #100000# fix to run this test 2009-06-22 09:41:04 +0200 msc r273200 : #100000# correct case 2009-06-22 09:02:42 +0200 msc r273199 : new SRB 2009-06-22 08:53:26 +0200 msc r273198 : #100000 2009-06-15 12:36:32 +0200 oj r272976 : test 2009-06-12 14:23:23 +0200 msc r272918 : #101587# unused feature was removed 2009-06-12 06:45:17 +0200 oj r272903 : use GUI instead of OS 2009-06-11 09:12:30 +0200 oj r272845 : remove unused dep 2009-06-11 09:11:09 +0200 oj r272844 : ColumnAliasInOrderBy not supported 2009-06-11 08:27:00 +0200 oj r272843 : CWS-TOOLING: rebase CWS dbaperf2 to trunk@272827 (milestone: DEV300:m50) 2009-06-10 15:30:17 +0200 msc r272822 : #100000 2009-06-10 15:27:40 +0200 msc r272820 : #102515# new function for the database type list 2009-06-10 15:26:09 +0200 msc r272818 : move file to dbaccess/tools/dbcreatetools.inc 2009-06-10 15:20:10 +0200 msc r272816 : #102515# new function for the database type list 2009-06-10 12:34:46 +0200 oj r272803 : #i101587# check extension 2009-06-10 11:53:45 +0200 oj r272800 : remove unused code 2009-06-09 09:57:25 +0200 oj r272752 : #i101587# EscapeDateTime moved into features section 2009-06-09 09:56:26 +0200 oj r272751 : enable finish 2009-06-08 11:50:37 +0200 oj r272726 : #i102588# move convert tzo saveDataSource 2009-06-05 11:54:20 +0200 jsk r272676 : #i102515# - NEW: Functions to retrieve Database names from API 2009-06-05 10:52:22 +0200 jsk r272671 : NEW: Functions to retrieve Database names from API 2009-06-05 09:36:54 +0200 oj r272666 : handle win and unx differently 2009-06-05 09:36:28 +0200 oj r272665 : handle win and unx differently 2009-06-04 13:41:56 +0200 oj r272625 : #i101268# make use of stringbuffer instead of oustring 2009-06-04 10:18:14 +0200 oj r272612 : add SAL_DLLPUBLIC_EXPORT 2009-05-28 10:56:33 +0200 oj r272381 : #i101587# create langpacks 2009-05-28 10:41:59 +0200 oj r272380 : #i101587# create langpacks 2009-05-28 10:29:30 +0200 oj r272379 : #i101587# create langpacks 2009-05-07 10:11:46 +0200 oj r271635 : fix compile warnings 2009-05-07 07:01:31 +0200 oj r271619 : change type from int32 to PathID 2009-05-07 06:53:19 +0200 oj r271618 : add all 2009-05-06 14:57:02 +0200 oj r271595 : add missing lib 2009-05-06 14:56:54 +0200 oj r271594 : no used anymore 2009-05-06 14:56:08 +0200 oj r271593 : no used anymore 2009-05-06 14:54:25 +0200 oj r271592 : no used anymore 2009-05-06 14:45:59 +0200 oj r271591 : add missing lib 2009-05-06 14:41:54 +0200 oj r271590 : change wnt 2009-05-06 14:22:21 +0200 oj r271589 : #i101587# use config for the drivers 2009-05-06 14:21:39 +0200 oj r271588 : #i101587# add new set for metadata and config data for driver 2009-05-06 14:19:36 +0200 oj r271587 : #i101587# handle metadata and props of driver 2009-05-06 10:11:11 +0200 oj r271570 : #i101587# correct wrong use of reference 2009-05-06 09:24:33 +0200 oj r271567 : #i101587# add new set for metadata 2009-05-06 08:52:06 +0200 oj r271563 : #i101587# add driver configuration 2009-05-06 08:51:04 +0200 oj r271562 : #i101587# add driver configuration 2009-05-04 10:24:41 +0200 oj r271442 : CWS-TOOLING: rebase CWS dbaperf2 to trunk@271427 (milestone: DEV300:m47) 2009-04-28 07:06:22 +0200 oj r271303 : compile error 2009-04-27 14:12:48 +0200 oj r271270 : #i101268# make use of stringbuffer instead of oustring 2009-04-27 14:12:27 +0200 oj r271269 : #i101268# make use of stringbuffer instead of oustring 2009-04-27 09:30:10 +0200 oj r271255 : use string buffer when possible 2009-04-24 11:56:01 +0200 oj r271207 : #i101268# remove end() call from loop 2009-04-23 14:24:03 +0200 oj r271171 : add dep 2009-04-23 13:25:25 +0200 oj r271164 : #i101268# add config entries for database drivers 2009-04-23 13:07:13 +0200 oj r271161 : #i101268# add config entries for database drivers 2009-04-23 13:06:33 +0200 oj r271160 : #i101268# add parent url pattern entry for driver node 2009-04-23 13:05:39 +0200 oj r271159 : #i101268# add config entry for driver node 2009-04-23 13:04:09 +0200 oj r271157 : #i101268# add config entry for driver node 2009-04-23 06:41:32 +0200 oj r271142 : #i101268# add new configuration file Drivers 2009-04-22 13:49:19 +0200 oj r271103 : convert EOL 2009-04-22 13:29:17 +0200 oj r271101 : #i101268# use of driver configuration entries for features and properties 2009-04-22 13:28:08 +0200 oj r271100 : #i101268# use of driver configuration entries for features and properties 2009-04-22 13:15:26 +0200 oj r271098 : #i101268# add new configuration file Drivers 2009-04-22 13:14:43 +0200 oj r271097 : #i101268# use of driver configuration entries for features and properties --- connectivity/inc/connectivity/DriversConfig.hxx | 88 +++ connectivity/inc/connectivity/dbmetadata.hxx | 7 + connectivity/inc/connectivity/sqlnode.hxx | 13 +- connectivity/makefile.pmk | 64 ++ connectivity/prj/build.lst | 14 +- connectivity/prj/d.lst | 4 + connectivity/qa/drivers/dbase/makefile.mk | 8 +- connectivity/source/commontools/DateConversion.cxx | 4 +- connectivity/source/commontools/DriversConfig.cxx | 241 ++++++ connectivity/source/commontools/FValue.cxx | 34 +- connectivity/source/commontools/dbconversion.cxx | 14 +- connectivity/source/commontools/dbmetadata.cxx | 10 +- connectivity/source/commontools/dbtools2.cxx | 86 +- connectivity/source/commontools/makefile.mk | 1 + connectivity/source/commontools/parameters.cxx | 18 +- connectivity/source/dbtools/makefile.mk | 1 + connectivity/source/drivers/adabas/adabas.xcu | 128 +++ connectivity/source/drivers/adabas/makefile.mk | 8 +- connectivity/source/drivers/ado/ado.xcu | 242 ++++++ connectivity/source/drivers/ado/makefile.mk | 13 +- connectivity/source/drivers/calc/calc.xcu | 66 ++ connectivity/source/drivers/calc/makefile.mk | 4 +- connectivity/source/drivers/dbase/DTable.cxx | 10 +- connectivity/source/drivers/dbase/dbase.xcu | 98 +++ connectivity/source/drivers/dbase/makefile.mk | 4 +- connectivity/source/drivers/evoab/LCatalog.cxx | 75 ++ connectivity/source/drivers/evoab/LCatalog.hxx | 52 ++ connectivity/source/drivers/evoab/LColumnAlias.cxx | 235 ++++++ connectivity/source/drivers/evoab/LColumnAlias.hxx | 116 +++ connectivity/source/drivers/evoab/LColumns.cxx | 60 ++ connectivity/source/drivers/evoab/LColumns.hxx | 55 ++ .../source/drivers/evoab/LConfigAccess.cxx | 164 ++++ .../source/drivers/evoab/LConfigAccess.hxx | 49 ++ connectivity/source/drivers/evoab/LConnection.cxx | 270 +++++++ connectivity/source/drivers/evoab/LConnection.hxx | 81 ++ .../source/drivers/evoab/LDatabaseMetaData.cxx | 394 ++++++++++ .../source/drivers/evoab/LDatabaseMetaData.hxx | 59 ++ connectivity/source/drivers/evoab/LDebug.cxx | 45 ++ connectivity/source/drivers/evoab/LDebug.hxx | 45 ++ connectivity/source/drivers/evoab/LDriver.cxx | 508 ++++++++++++ connectivity/source/drivers/evoab/LDriver.hxx | 118 +++ connectivity/source/drivers/evoab/LFolderList.cxx | 566 +++++++++++++ connectivity/source/drivers/evoab/LFolderList.hxx | 95 +++ connectivity/source/drivers/evoab/LNoException.cxx | 327 ++++++++ .../source/drivers/evoab/LPreparedStatement.cxx | 46 ++ .../source/drivers/evoab/LPreparedStatement.hxx | 53 ++ connectivity/source/drivers/evoab/LResultSet.cxx | 193 +++++ connectivity/source/drivers/evoab/LResultSet.hxx | 84 ++ connectivity/source/drivers/evoab/LServices.cxx | 178 +++++ connectivity/source/drivers/evoab/LStatement.cxx | 46 ++ connectivity/source/drivers/evoab/LStatement.hxx | 52 ++ connectivity/source/drivers/evoab/LTable.cxx | 873 +++++++++++++++++++++ connectivity/source/drivers/evoab/LTable.hxx | 103 +++ connectivity/source/drivers/evoab/LTables.cxx | 65 ++ connectivity/source/drivers/evoab/LTables.hxx | 55 ++ connectivity/source/drivers/evoab/evoab.map | 8 + connectivity/source/drivers/evoab/evoab.xcu | 64 ++ connectivity/source/drivers/evoab/evoab.xml | 33 + connectivity/source/drivers/evoab/exports.dxp | 3 + connectivity/source/drivers/evoab/makefile.mk | 108 +++ connectivity/source/drivers/evoab2/evoab2.xcu | 79 ++ connectivity/source/drivers/evoab2/makefile.mk | 4 +- .../source/drivers/file/FStringFunctions.cxx | 13 +- connectivity/source/drivers/flat/flat.xcu | 113 +++ connectivity/source/drivers/flat/makefile.mk | 4 +- connectivity/source/drivers/hsqldb/hsqldb.xcu | 76 ++ connectivity/source/drivers/hsqldb/makefile.mk | 4 +- connectivity/source/drivers/jdbc/jdbc.xcu | 207 +++++ connectivity/source/drivers/jdbc/makefile.mk | 4 +- connectivity/source/drivers/jdbc/tools.cxx | 3 + connectivity/source/drivers/kab/kab.xcu | 49 ++ connectivity/source/drivers/kab/makefile.mk | 4 +- connectivity/source/drivers/macab/macab.xcu | 49 ++ connectivity/source/drivers/macab/makefile.mk | 4 +- connectivity/source/drivers/mozab/makefile.mk | 28 +- connectivity/source/drivers/mozab/mozab.xcu | 157 ++++ connectivity/source/drivers/mozab/mozab2.xcu | 121 +++ connectivity/source/drivers/mysql/makefile.mk | 4 +- connectivity/source/drivers/mysql/mysql.xcu | 177 +++++ connectivity/source/drivers/odbc/makefile.mk | 4 +- connectivity/source/drivers/odbc/odbc.xcu | 173 ++++ connectivity/source/drivers/odbcbase/OTools.cxx | 10 +- connectivity/source/manager/makefile.mk | 3 + connectivity/source/manager/mdrivermanager.cxx | 49 +- connectivity/source/manager/mdrivermanager.hxx | 8 +- connectivity/source/manager/mregistration.cxx | 6 +- connectivity/source/parse/sqlnode.cxx | 131 ++-- connectivity/target.pmk | 37 + connectivity/util/delzip | 0 connectivity/util/langfilter.xsl | 37 + connectivity/util/makefile.mk | 80 ++ officecfg/prj/build.lst | 33 +- officecfg/prj/d.lst | 4 + .../org/openoffice/Office/DataAccess/Drivers.xcs | 100 +++ .../org/openoffice/Office/DataAccess/makefile.mk | 46 ++ 95 files changed, 8034 insertions(+), 245 deletions(-) create mode 100755 connectivity/inc/connectivity/DriversConfig.hxx create mode 100755 connectivity/makefile.pmk create mode 100755 connectivity/source/commontools/DriversConfig.cxx create mode 100755 connectivity/source/drivers/adabas/adabas.xcu create mode 100755 connectivity/source/drivers/ado/ado.xcu create mode 100755 connectivity/source/drivers/calc/calc.xcu create mode 100755 connectivity/source/drivers/dbase/dbase.xcu create mode 100644 connectivity/source/drivers/evoab/LCatalog.cxx create mode 100644 connectivity/source/drivers/evoab/LCatalog.hxx create mode 100644 connectivity/source/drivers/evoab/LColumnAlias.cxx create mode 100644 connectivity/source/drivers/evoab/LColumnAlias.hxx create mode 100644 connectivity/source/drivers/evoab/LColumns.cxx create mode 100644 connectivity/source/drivers/evoab/LColumns.hxx create mode 100644 connectivity/source/drivers/evoab/LConfigAccess.cxx create mode 100644 connectivity/source/drivers/evoab/LConfigAccess.hxx create mode 100644 connectivity/source/drivers/evoab/LConnection.cxx create mode 100644 connectivity/source/drivers/evoab/LConnection.hxx create mode 100644 connectivity/source/drivers/evoab/LDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/evoab/LDatabaseMetaData.hxx create mode 100644 connectivity/source/drivers/evoab/LDebug.cxx create mode 100644 connectivity/source/drivers/evoab/LDebug.hxx create mode 100644 connectivity/source/drivers/evoab/LDriver.cxx create mode 100644 connectivity/source/drivers/evoab/LDriver.hxx create mode 100644 connectivity/source/drivers/evoab/LFolderList.cxx create mode 100644 connectivity/source/drivers/evoab/LFolderList.hxx create mode 100644 connectivity/source/drivers/evoab/LNoException.cxx create mode 100644 connectivity/source/drivers/evoab/LPreparedStatement.cxx create mode 100644 connectivity/source/drivers/evoab/LPreparedStatement.hxx create mode 100644 connectivity/source/drivers/evoab/LResultSet.cxx create mode 100644 connectivity/source/drivers/evoab/LResultSet.hxx create mode 100644 connectivity/source/drivers/evoab/LServices.cxx create mode 100644 connectivity/source/drivers/evoab/LStatement.cxx create mode 100644 connectivity/source/drivers/evoab/LStatement.hxx create mode 100644 connectivity/source/drivers/evoab/LTable.cxx create mode 100644 connectivity/source/drivers/evoab/LTable.hxx create mode 100644 connectivity/source/drivers/evoab/LTables.cxx create mode 100644 connectivity/source/drivers/evoab/LTables.hxx create mode 100644 connectivity/source/drivers/evoab/evoab.map create mode 100755 connectivity/source/drivers/evoab/evoab.xcu create mode 100644 connectivity/source/drivers/evoab/evoab.xml create mode 100644 connectivity/source/drivers/evoab/exports.dxp create mode 100644 connectivity/source/drivers/evoab/makefile.mk create mode 100755 connectivity/source/drivers/evoab2/evoab2.xcu create mode 100755 connectivity/source/drivers/flat/flat.xcu create mode 100755 connectivity/source/drivers/hsqldb/hsqldb.xcu create mode 100755 connectivity/source/drivers/jdbc/jdbc.xcu create mode 100755 connectivity/source/drivers/kab/kab.xcu create mode 100755 connectivity/source/drivers/macab/macab.xcu create mode 100755 connectivity/source/drivers/mozab/mozab.xcu create mode 100755 connectivity/source/drivers/mozab/mozab2.xcu create mode 100755 connectivity/source/drivers/mysql/mysql.xcu create mode 100755 connectivity/source/drivers/odbc/odbc.xcu create mode 100755 connectivity/target.pmk create mode 100755 connectivity/util/delzip create mode 100755 connectivity/util/langfilter.xsl create mode 100755 connectivity/util/makefile.mk create mode 100755 officecfg/registry/schema/org/openoffice/Office/DataAccess/Drivers.xcs create mode 100755 officecfg/registry/schema/org/openoffice/Office/DataAccess/makefile.mk diff --git a/connectivity/inc/connectivity/DriversConfig.hxx b/connectivity/inc/connectivity/DriversConfig.hxx new file mode 100755 index 000000000000..8a33019d57ed --- /dev/null +++ b/connectivity/inc/connectivity/DriversConfig.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: makefile,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: st $ $Date: 2000/11/22 02:32:00 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#ifndef CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED +#define CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED + +#include +#include +#include +#include +#include "connectivity/dbtoolsdllapi.hxx" +#include +#include +#include + +namespace connectivity +{ + typedef struct + { + ::comphelper::NamedValueCollection aProperties; + ::comphelper::NamedValueCollection aFeatures; + ::comphelper::NamedValueCollection aMetaData; + ::rtl::OUString sDriverFactory; + ::rtl::OUString sDriverTypeDisplayName; + } TInstalledDriver; + DECLARE_STL_USTRINGACCESS_MAP( TInstalledDriver, TInstalledDrivers); + + class DriversConfigImpl + { + ::utl::OConfigurationTreeRoot m_aInstalled; + public: + DriversConfigImpl(); + void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,TInstalledDrivers& _rDrivers); + }; + // + // Allows to access all driver which are located in the configuration + // + class OOO_DLLPUBLIC_DBTOOLS DriversConfig + { + typedef salhelper::SingletonRef OSharedConfigNode; + + const ::comphelper::NamedValueCollection& impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const; + public: + DriversConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + + ::rtl::OUString getDriverFactoryName(const ::rtl::OUString& _sUrl) const; + ::rtl::OUString getDriverTypeDisplayName(const ::rtl::OUString& _sUrl) const; + const ::comphelper::NamedValueCollection& getProperties(const ::rtl::OUString& _sURL) const; + const ::comphelper::NamedValueCollection& getFeatures(const ::rtl::OUString& _sURL) const; + const ::comphelper::NamedValueCollection& getMetaData(const ::rtl::OUString& _sURL) const; + ::com::sun::star::uno::Sequence< ::rtl::OUString > getURLs() const; + private: + TInstalledDrivers m_aDrivers; + OSharedConfigNode m_aNode; + }; +} +#endif // CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx index ea284efb2b86..32662c5c157a 100644 --- a/connectivity/inc/connectivity/dbmetadata.hxx +++ b/connectivity/inc/connectivity/dbmetadata.hxx @@ -135,8 +135,15 @@ namespace dbtools SELECT * FROM table correlation_name is generated. */ bool generateASBeforeCorrelationName() const; + + /** should date time be escaped like '2001-01-01' => #2001-01-01# + */ bool shouldEscapeDateTime() const; + /** auto increment columns should be automaticly used as primary key. + */ + bool isAutoIncrementPrimaryKey() const; + /** determines the syntax to use for boolean comparison predicates @see ::com::sun::star::sdb::BooleanComparisonMode diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 7dbc59e0cde8..fda3e24c09e6 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -39,6 +39,7 @@ #include #include #include +#include // forward declarations namespace com @@ -428,22 +429,22 @@ namespace connectivity bool _bSubstitute) const; private: - void impl_parseNodeToString_throw( ::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const; - void impl_parseLikeNodeToString_throw( ::rtl::OUString& rString, const SQLParseNodeParameter& rParam ) const; - void impl_parseTableRangeNodeToString_throw( ::rtl::OUString& rString, const SQLParseNodeParameter& rParam ) const; + void impl_parseNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; + void impl_parseLikeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const; + void impl_parseTableRangeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const; /** parses a table_name node into a SQL statement particle. @return if and only if parsing was successful, if default handling should be applied. */ - bool impl_parseTableNameNodeToString_throw( ::rtl::OUString& rString, const SQLParseNodeParameter& rParam ) const; + bool impl_parseTableNameNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const; - sal_Bool addDateValue(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const; + sal_Bool addDateValue(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; ::rtl::OUString convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; ::rtl::OUString convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; ::rtl::OUString convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; - void parseLeaf(::rtl::OUString & rString, const SQLParseNodeParameter& rParam) const; + void parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; }; //----------------------------------------------------------------------------- diff --git a/connectivity/makefile.pmk b/connectivity/makefile.pmk new file mode 100755 index 000000000000..4a8dbdf6059d --- /dev/null +++ b/connectivity/makefile.pmk @@ -0,0 +1,64 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.pmk,v $ +# +# $Revision: 1.6 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +XSLDIR=$(SOLARXMLDIR)$/processing +ABSXCSROOT=$(PWD)$/$(MISC) +# ABSXCSROOT=$(MISC) +XCSROOT=.. +# XCSROOT=$(SOLARXMLDIR) +# ABSXCSROOT=$(SOLARXMLDIR) +DTDDIR=$(SOLARXMLDIR) +PROCESSOUT=$(MISC) +PROCESSORDIR=$(SOLARBINDIR) + + +# no validation by inspector class +NO_INSPECTION=TRUE + +JAVAPREPRO= +.IF "$(JDK_VERSION)" == "110" +JAVAPREPRO=-jdk11 +.ENDIF +.IF "$(PRODUCT)" != "" +JAVAPREPRO=$(JAVAPREPRO) + " -product" +.ENDIF + +# --- Settings ----------------------------------------------------- +PACKAGE=org.openoffice.Office.DataAccess +.INCLUDE : settings.mk + +LOCALIZEDFILES= \ + $(TARGET).xcu + +XCUFILES= \ + $(LOCALIZEDFILES) \ + + diff --git a/connectivity/prj/build.lst b/connectivity/prj/build.lst index 077c241b9fd8..21326f36023a 100644 --- a/connectivity/prj/build.lst +++ b/connectivity/prj/build.lst @@ -1,19 +1,19 @@ -cn connectivity : l10n comphelper MOZ:moz SO:moz_prebuilt svtools UNIXODBC:unixODBC unoil javaunohelper HSQLDB:hsqldb QADEVOOO:qadevOOo NULL +cn connectivity : l10n comphelper MOZ:moz SO:moz_prebuilt svtools UNIXODBC:unixODBC unoil javaunohelper HSQLDB:hsqldb QADEVOOO:qadevOOo officecfg NULL cn connectivity usr1 - all cn_mkout NULL cn connectivity\inc nmake - all cn_inc NULL cn connectivity\com\sun\star\sdbcx\comp\hsqldb nmake - all cn_jhsqldbdb cn_hsqldb cn_inc NULL cn connectivity\source\commontools nmake - all cn_cmtools cn_parse cn_inc NULL -cn connectivity\source\manager nmake - all cn_manager cn_inc NULL +cn connectivity\source\manager nmake - all cn_manager cn_dbtools cn_inc NULL cn connectivity\source\cpool nmake - all cn_cpool cn_dbtools cn_inc NULL cn connectivity\source\resource nmake - all cn_res cn_inc NULL cn connectivity\source\sdbcx nmake - all cn_sdbcx cn_inc NULL -cn connectivity\source\drivers\ado nmake - w cn_ado cn_dbtools cn_inc NULL +cn connectivity\source\drivers\ado nmake - all cn_ado cn_dbtools cn_inc NULL cn connectivity\source\drivers\mozab\mozillasrc nmake - all cn_mozab_mozillasrc cn_file cn_inc NULL cn connectivity\source\drivers\mozab\bootstrap nmake - all cn_mozab_bootstrap cn_mozab_mozillasrc cn_inc NULL cn connectivity\source\drivers\mozab nmake - all cn_mozab cn_mozab_bootstrap cn_dbtools cn_inc NULL -cn connectivity\source\drivers\kab nmake - u cn_kab cn_dbtools cn_inc NULL -cn connectivity\source\drivers\macab nmake - u cn_macab cn_dbtools cn_inc NULL -cn connectivity\source\drivers\evoab2 nmake - u cn_evoab2 cn_dbtools cn_file cn_inc NULL +cn connectivity\source\drivers\kab nmake - all cn_kab cn_dbtools cn_inc NULL +cn connectivity\source\drivers\macab nmake - all cn_macab cn_dbtools cn_inc NULL +cn connectivity\source\drivers\evoab2 nmake - all cn_evoab2 cn_dbtools cn_file cn_inc NULL cn connectivity\source\drivers\calc nmake - all cn_calc cn_file cn_inc NULL cn connectivity\source\drivers\odbcbase nmake - all cn_odbcbase cn_dbtools cn_inc NULL cn connectivity\source\drivers\odbc nmake - all cn_odbc cn_odbcbase cn_inc NULL @@ -28,3 +28,5 @@ cn connectivity\source\parse nmake - all cn_parse cn_ cn connectivity\source\simpledbt nmake - all cn_simpledbt cn_cmtools cn_inc NULL cn connectivity\source\dbtools nmake - all cn_dbtools cn_simpledbt cn_cmtools cn_parse cn_res cn_sdbcx cn_inc cn_res NULL cn connectivity\qa\connectivity\tools nmake - all cn_qa_tools cn_inc NULL +cn connectivity\util nmake - all cn_util cn_ado cn_mozab cn_kab cn_evoab2 cn_calc cn_odbc cn_mysql cn_jdbc cn_adabas cn_flat cn_dbase cn_hsqldb NULL + diff --git a/connectivity/prj/d.lst b/connectivity/prj/d.lst index 36d93ca2c35b..728c8fef03c4 100644 --- a/connectivity/prj/d.lst +++ b/connectivity/prj/d.lst @@ -22,8 +22,12 @@ mkdir: %_DEST%\inc%_EXT%\connectivity mkdir: %_DEST%\inc%_EXT%\connectivity\sdbcx +mkdir: %_DEST%\xml%_EXT%\registry\spool\DataAccess ..\inc\connectivity\*.hxx %_DEST%\inc%_EXT%\connectivity\*.hxx ..\%__SRC%\inc\sqlbison.hxx %_DEST%\inc%_EXT%\connectivity\sqlbison.hxx ..\inc\connectivity\sdbcx\*.hxx %_DEST%\inc%_EXT%\connectivity\sdbcx\*.hxx #..\version.mk %_DEST%\inc%_EXT%\connectivity\version.mk +..\%__SRC%\misc\registry\data\org\openoffice\Office\DataAccess\*.xcu %_DEST%\xml%_EXT%\registry\spool\DataAccess\*.xcu +..\%COMMON_OUTDIR%\bin\fcfg_drivers_*.zip %_DEST%\pck%_EXT%\fcfg_drivers_*.zip +..\%__SRC%\bin\fcfg_drivers_*.zip %_DEST%\pck%_EXT%\fcfg_drivers_*.zip \ No newline at end of file diff --git a/connectivity/qa/drivers/dbase/makefile.mk b/connectivity/qa/drivers/dbase/makefile.mk index 63a4d5a25569..f7d2f79a7432 100644 --- a/connectivity/qa/drivers/dbase/makefile.mk +++ b/connectivity/qa/drivers/dbase/makefile.mk @@ -59,15 +59,9 @@ JARCOMPRESS = TRUE # --- Targets ------------------------------------------------------ -.IF "$(depend)" == "" -ALL : ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF - .INCLUDE : target.mk run: - java -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar org.openoffice.Runner -TestBase java_complex -o complex.connectivity.$(TARGET) + java -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex -o complex.connectivity.$(TARGET) diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index e58e292bb91b..5c43e5d50cf1 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -93,8 +93,8 @@ using namespace ::com::sun::star::beans; ::rtl::OUString aTemp; _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; sal_Int32 nIndex = (sal_Int32)-1; - ::rtl::OUString sQuot(RTL_CONSTASCII_USTRINGPARAM("\'")); - ::rtl::OUString sQuotToReplace(RTL_CONSTASCII_USTRINGPARAM("\'\'")); + const ::rtl::OUString sQuot(RTL_CONSTASCII_USTRINGPARAM("\'")); + const ::rtl::OUString sQuotToReplace(RTL_CONSTASCII_USTRINGPARAM("\'\'")); do { nIndex += 2; diff --git a/connectivity/source/commontools/DriversConfig.cxx b/connectivity/source/commontools/DriversConfig.cxx new file mode 100755 index 000000000000..906024f452a4 --- /dev/null +++ b/connectivity/source/commontools/DriversConfig.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: makefile,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: st $ $Date: 2000/11/22 02:32:00 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 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 + * + ************************************************************************/ +#include "connectivity/DriversConfig.hxx" +#include + +using namespace connectivity; +using namespace utl; +using namespace ::com::sun::star; + +namespace +{ + void lcl_convert(const uno::Sequence< ::rtl::OUString >& _aSource,uno::Any& _rDest) + { + uno::Sequence aRet(_aSource.getLength()); + uno::Any* pAny = aRet.getArray(); + const ::rtl::OUString* pIter = _aSource.getConstArray(); + const ::rtl::OUString* pEnd = pIter + _aSource.getLength(); + for (;pIter != pEnd ; ++pIter,++pAny) + { + *pAny <<= *pIter; + } + _rDest <<= aRet; + } + void lcl_fillValues(const ::utl::OConfigurationNode& _aURLPatternNode,const ::rtl::OUString& _sNode,::comphelper::NamedValueCollection& _rValues) + { + const ::utl::OConfigurationNode aPropertiesNode = _aURLPatternNode.openNode(_sNode); + if ( aPropertiesNode.isValid() ) + { + uno::Sequence< ::rtl::OUString > aStringSeq; + static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("/Value")); + const uno::Sequence< ::rtl::OUString > aProperties = aPropertiesNode.getNodeNames(); + const ::rtl::OUString* pPropertiesIter = aProperties.getConstArray(); + const ::rtl::OUString* pPropertiesEnd = pPropertiesIter + aProperties.getLength(); + for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) + { + uno::Any aValue = aPropertiesNode.getNodeValue(*pPropertiesIter + s_sValue); + if ( aValue >>= aStringSeq ) + { + lcl_convert(aStringSeq,aValue); + } + _rValues.put(*pPropertiesIter,aValue); + } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter,++pNamedIter) + } // if ( aPropertiesNode.isValid() ) + } + void lcl_readURLPatternNode(const ::utl::OConfigurationTreeRoot& _aInstalled,const ::rtl::OUString& _sEntry,TInstalledDriver& _rInstalledDriver) + { + const ::utl::OConfigurationNode aURLPatternNode = _aInstalled.openNode(_sEntry); + if ( aURLPatternNode.isValid() ) + { + static const ::rtl::OUString s_sParentURLPattern(RTL_CONSTASCII_USTRINGPARAM("ParentURLPattern")); + static const ::rtl::OUString s_sDriver(RTL_CONSTASCII_USTRINGPARAM("Driver")); + static const ::rtl::OUString s_sDriverTypeDisplayName(RTL_CONSTASCII_USTRINGPARAM("DriverTypeDisplayName")); + static const ::rtl::OUString s_sProperties(RTL_CONSTASCII_USTRINGPARAM("Properties")); + static const ::rtl::OUString s_sFeatures(RTL_CONSTASCII_USTRINGPARAM("Features")); + static const ::rtl::OUString s_sMetaData(RTL_CONSTASCII_USTRINGPARAM("MetaData")); + ::rtl::OUString sParentURLPattern; + aURLPatternNode.getNodeValue(s_sParentURLPattern) >>= sParentURLPattern; + if ( sParentURLPattern.getLength() ) + lcl_readURLPatternNode(_aInstalled,sParentURLPattern,_rInstalledDriver); + + ::rtl::OUString sDriverFactory; + aURLPatternNode.getNodeValue(s_sDriver) >>= sDriverFactory; + if ( sDriverFactory.getLength() ) + _rInstalledDriver.sDriverFactory = sDriverFactory; + + ::rtl::OUString sDriverTypeDisplayName; + aURLPatternNode.getNodeValue(s_sDriverTypeDisplayName) >>= sDriverTypeDisplayName; + OSL_ENSURE(sDriverTypeDisplayName.getLength(),"No valid DriverTypeDisplayName property!"); + if ( sDriverTypeDisplayName.getLength() ) + _rInstalledDriver.sDriverTypeDisplayName = sDriverTypeDisplayName; + + lcl_fillValues(aURLPatternNode,s_sProperties,_rInstalledDriver.aProperties); + lcl_fillValues(aURLPatternNode,s_sFeatures,_rInstalledDriver.aFeatures); + lcl_fillValues(aURLPatternNode,s_sMetaData,_rInstalledDriver.aMetaData); + } + } +} +// ----------------------------------------------------------------------------- +DriversConfigImpl::DriversConfigImpl() +{ +} +// ----------------------------------------------------------------------------- +void DriversConfigImpl::Load(const uno::Reference< lang::XMultiServiceFactory >& _rxORB,TInstalledDrivers& _rDrivers) +{ + if ( !m_aInstalled.isValid() ) + { + static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess.Drivers/Installed")); ///Installed + m_aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(_rxORB, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); + } + + if ( m_aInstalled.isValid() ) + { + const uno::Sequence< ::rtl::OUString > aURLPatterns = m_aInstalled.getNodeNames(); + const ::rtl::OUString* pPatternIter = aURLPatterns.getConstArray(); + const ::rtl::OUString* pPatternEnd = pPatternIter + aURLPatterns.getLength(); + for (;pPatternIter != pPatternEnd ; ++pPatternIter) + { + TInstalledDriver aInstalledDriver; + lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver); + if ( aInstalledDriver.sDriverFactory.getLength() ) + _rDrivers.insert(TInstalledDrivers::value_type(*pPatternIter,aInstalledDriver)); + } + } +} +// ----------------------------------------------------------------------------- +DriversConfig::DriversConfig(const uno::Reference< lang::XMultiServiceFactory >& _rxORB) +{ + m_aNode->Load(_rxORB,m_aDrivers); +} +// ----------------------------------------------------------------------------- +::rtl::OUString DriversConfig::getDriverFactoryName(const ::rtl::OUString& _sURL) const +{ + ::rtl::OUString sRet; + ::rtl::OUString sOldPattern; + TInstalledDrivers::const_iterator aIter = m_aDrivers.begin(); + TInstalledDrivers::const_iterator aEnd = m_aDrivers.end(); + for(;aIter != aEnd;++aIter) + { + WildCard aWildCard(aIter->first); + if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) ) + { + sRet = aIter->second.sDriverFactory; + sOldPattern = aIter->first; + } + } + + return sRet; +} +// ----------------------------------------------------------------------------- +::rtl::OUString DriversConfig::getDriverTypeDisplayName(const ::rtl::OUString& _sURL) const +{ + ::rtl::OUString sRet; + ::rtl::OUString sOldPattern; + TInstalledDrivers::const_iterator aIter = m_aDrivers.begin(); + TInstalledDrivers::const_iterator aEnd = m_aDrivers.end(); + for(;aIter != aEnd;++aIter) + { + WildCard aWildCard(aIter->first); + if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) ) + { + sRet = aIter->second.sDriverTypeDisplayName; + sOldPattern = aIter->first; + } + } + + return sRet; +} +// ----------------------------------------------------------------------------- +const ::comphelper::NamedValueCollection& DriversConfig::getProperties(const ::rtl::OUString& _sURL) const +{ + return impl_get(_sURL,1); +} +// ----------------------------------------------------------------------------- +const ::comphelper::NamedValueCollection& DriversConfig::getFeatures(const ::rtl::OUString& _sURL) const +{ + return impl_get(_sURL,0); +} +// ----------------------------------------------------------------------------- +const ::comphelper::NamedValueCollection& DriversConfig::getMetaData(const ::rtl::OUString& _sURL) const +{ + return impl_get(_sURL,2); +} +// ----------------------------------------------------------------------------- +const ::comphelper::NamedValueCollection& DriversConfig::impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const +{ + const ::comphelper::NamedValueCollection* pRet = NULL; + ::rtl::OUString sOldPattern; + TInstalledDrivers::const_iterator aIter = m_aDrivers.begin(); + TInstalledDrivers::const_iterator aEnd = m_aDrivers.end(); + for(;aIter != aEnd;++aIter) + { + WildCard aWildCard(aIter->first); + if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) ) + { + switch(_nProps) + { + case 0: + pRet = &aIter->second.aFeatures; + break; + case 1: + pRet = &aIter->second.aProperties; + break; + case 2: + pRet = &aIter->second.aMetaData; + break; + } + sOldPattern = aIter->first; + } + } // for(;aIter != aEnd;++aIter) + if ( pRet == NULL ) + { + static const ::comphelper::NamedValueCollection s_sEmpty; + pRet = &s_sEmpty; + } + return *pRet; +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > DriversConfig::getURLs() const +{ + uno::Sequence< ::rtl::OUString > aRet(m_aDrivers.size()); + ::rtl::OUString* pIter = aRet.getArray(); + TInstalledDrivers::const_iterator aIter = m_aDrivers.begin(); + TInstalledDrivers::const_iterator aEnd = m_aDrivers.end(); + for(;aIter != aEnd;++aIter,++pIter) + { + *pIter = aIter->first; + } + return aRet; +} diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 433b5ffc69ec..cd09efa227fe 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include using namespace connectivity; @@ -984,12 +985,13 @@ Any ORowSetValue::makeAny() const case DataType::VARBINARY: case DataType::LONGVARBINARY: { - aRet = ::rtl::OUString::createFromAscii("0x"); + ::rtl::OUStringBuffer sVal = ::rtl::OUString::createFromAscii("0x"); Sequence aSeq(getSequence()); const sal_Int8* pBegin = aSeq.getConstArray(); const sal_Int8* pEnd = pBegin + aSeq.getLength(); for(;pBegin != pEnd;++pBegin) - aRet += ::rtl::OUString::valueOf((sal_Int32)*pBegin,16); + sVal.append((sal_Int32)*pBegin,16); + aRet = sVal.makeStringAndClear(); } break; case DataType::BIT: @@ -1972,20 +1974,20 @@ void ORowSetValue::fill(const Any& _rValue) setSigned(sal_False); break; } - case TypeClass_HYPER: - { - sal_Int64 nValue(0); - _rValue >>= nValue; - (*this) = nValue; - break; - } - case TypeClass_UNSIGNED_HYPER: - { - sal_uInt64 nValue(0); - _rValue >>= nValue; - (*this) = static_cast(nValue); - setSigned(sal_False); - break; + case TypeClass_HYPER: + { + sal_Int64 nValue(0); + _rValue >>= nValue; + (*this) = nValue; + break; + } + case TypeClass_UNSIGNED_HYPER: + { + sal_uInt64 nValue(0); + _rValue >>= nValue; + (*this) = static_cast(nValue); + setSigned(sal_False); + break; } case TypeClass_UNSIGNED_LONG: { diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx index 995c5323bc89..47c6143e6507 100644 --- a/connectivity/source/commontools/dbconversion.cxx +++ b/connectivity/source/commontools/dbconversion.cxx @@ -40,7 +40,7 @@ #include #include #include - +#include #define MAX_DAYS 3636532 @@ -96,13 +96,13 @@ namespace dbtools ::rtl::OUString DBTypeConversion::toDateTimeString(const DateTime& _rDateTime) { Date aDate(_rDateTime.Day,_rDateTime.Month,_rDateTime.Year); - ::rtl::OUString aTemp(toDateString(aDate)); - aTemp += ::rtl::OUString::createFromAscii(" "); + ::rtl::OUStringBuffer aTemp(toDateString(aDate)); + aTemp.appendAscii(" "); Time aTime(0,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours); - aTemp += toTimeString(aTime); - aTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); - aTemp += ::rtl::OUString::valueOf(static_cast(_rDateTime.HundredthSeconds)); - return aTemp; + aTemp.append(toTimeString(aTime)); + aTemp.appendAscii("."); + aTemp.append(static_cast(_rDateTime.HundredthSeconds)); + return aTemp.makeStringAndClear(); } //------------------------------------------------------------------------------ Date DBTypeConversion::toDate(sal_Int32 _nVal) diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 66d2791c3fce..0d47cffce0ab 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -276,7 +276,15 @@ namespace dbtools OSL_VERIFY( setting >>= doGenerate ); return doGenerate; } - + //-------------------------------------------------------------------- + bool DatabaseMetaData::isAutoIncrementPrimaryKey() const + { + bool doGenerate( true ); + Any setting; + if ( lcl_getConnectionSetting( "AutoIncrementIsPrimaryKey", *m_pImpl, setting ) ) + OSL_VERIFY( setting >>= doGenerate ); + return doGenerate; + } //-------------------------------------------------------------------- sal_Int32 DatabaseMetaData::getBooleanComparisonMode() const { diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index cc842f56e008..1e1fa87cc58e 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -86,10 +86,10 @@ namespace dbtools sal_Int32 nPrecision = 0; sal_Int32 nScale = 0; - ::rtl::OUString sQuoteString = xMetaData->getIdentifierQuoteString(); - ::rtl::OUString aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + const ::rtl::OUString sQuoteString = xMetaData->getIdentifierQuoteString(); + ::rtl::OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); - aSql += ::rtl::OUString::createFromAscii(" "); + aSql.appendAscii(" "); nDataType = nPrecision = nScale = 0; sal_Bool bIsAutoIncrement = sal_False; @@ -143,54 +143,59 @@ namespace dbtools sal_Int32 nParenPos = sTypeName.indexOf('('); if ( nParenPos == -1 ) { - aSql += sTypeName; - aSql += ::rtl::OUString::createFromAscii("("); + aSql.append(sTypeName); + aSql.appendAscii("("); } else { - aSql += sTypeName.copy(0,++nParenPos); + aSql.append(sTypeName.copy(0,++nParenPos)); } if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP ) { - aSql += ::rtl::OUString::valueOf(nPrecision); + aSql.append(nPrecision); if ( (nScale > 0) || (_sCreatePattern.getLength() && sCreateParams.indexOf(_sCreatePattern) != -1) ) - aSql += ::rtl::OUString::createFromAscii(","); + aSql.appendAscii(","); } if ( (nScale > 0) || (_sCreatePattern.getLength() && sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == DataType::TIMESTAMP ) - aSql += ::rtl::OUString::valueOf(nScale); + aSql.append(nScale); if ( nParenPos == -1 ) - aSql += ::rtl::OUString::createFromAscii(")"); + aSql.appendAscii(")"); else { nParenPos = sTypeName.indexOf(')',nParenPos); - aSql += sTypeName.copy(nParenPos); + aSql.append(sTypeName.copy(nParenPos)); } } else - aSql += sTypeName; // simply add the type name + aSql.append(sTypeName); // simply add the type name ::rtl::OUString aDefault = ::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); - if(aDefault.getLength()) - aSql += ::rtl::OUString::createFromAscii(" DEFAULT ") + sPreFix + aDefault + sPostFix; + if ( aDefault.getLength() ) + { + aSql.append(::rtl::OUString::createFromAscii(" DEFAULT ")); + aSql.append(sPreFix); + aSql.append(aDefault); + aSql.append(sPostFix); + } // if ( aDefault.getLength() ) if(::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS) - aSql += ::rtl::OUString::createFromAscii(" NOT NULL"); + aSql.append(::rtl::OUString::createFromAscii(" NOT NULL")); if ( bIsAutoIncrement && sAutoIncrementValue.getLength()) { - aSql += ::rtl::OUString::createFromAscii(" "); - aSql += sAutoIncrementValue; + aSql.appendAscii(" "); + aSql.append(sAutoIncrementValue); } - return aSql; + return aSql.makeStringAndClear(); } // ----------------------------------------------------------------------------- ::rtl::OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sCreatePattern) { - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); ::rtl::OUString sCatalog,sSchema,sTable,sComposedName; Reference xMetaData = _xConnection->getMetaData(); @@ -204,7 +209,8 @@ namespace dbtools if ( !sComposedName.getLength() ) ::dbtools::throwFunctionSequenceException(_xConnection); - aSql += sComposedName + ::rtl::OUString::createFromAscii(" ("); + aSql.append(sComposedName); + aSql.append(::rtl::OUString::createFromAscii(" (")); // columns Reference xColumnSup(descriptor,UNO_QUERY); @@ -220,11 +226,11 @@ namespace dbtools { if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() ) { - aSql += createStandardColumnPart(xColProp,_xConnection,_sCreatePattern); - aSql += ::rtl::OUString::createFromAscii(","); + aSql.append(createStandardColumnPart(xColProp,_xConnection,_sCreatePattern)); + aSql.appendAscii(","); } } - return aSql; + return aSql.makeStringAndClear(); } namespace { @@ -256,7 +262,7 @@ namespace Reference xMetaData = _xConnection->getMetaData(); ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); - ::rtl::OUString aSql; + ::rtl::OUStringBuffer aSql; // keys Reference xKeySup(descriptor,UNO_QUERY); Reference xKeys = xKeySup->getKeys(); @@ -286,8 +292,8 @@ namespace ::dbtools::throwFunctionSequenceException(_xConnection); const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString(); - aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY "); - aSql += generateColumnNames(xColumns,xMetaData); + aSql.append(::rtl::OUString::createFromAscii(" PRIMARY KEY ")); + aSql.append(generateColumnNames(xColumns,xMetaData)); } else if(nKeyType == KeyType::UNIQUE) { @@ -297,8 +303,8 @@ namespace ::dbtools::throwFunctionSequenceException(_xConnection); const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString(); - aSql += ::rtl::OUString::createFromAscii(" UNIQUE "); - aSql += generateColumnNames(xColumns,xMetaData); + aSql.append(::rtl::OUString::createFromAscii(" UNIQUE ")); + aSql.append(generateColumnNames(xColumns,xMetaData)); } else if(nKeyType == KeyType::FOREIGN) { @@ -309,7 +315,7 @@ namespace if(!xColumns.is() || !xColumns->getCount()) ::dbtools::throwFunctionSequenceException(_xConnection); - aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY "); + aSql.append(::rtl::OUString::createFromAscii(" FOREIGN KEY ")); ::rtl::OUString sRefTable = getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE))); ::dbtools::qualifiedNameComponents(xMetaData, sRefTable, @@ -323,21 +329,21 @@ namespace if ( !sComposedName.getLength() ) ::dbtools::throwFunctionSequenceException(_xConnection); - aSql += generateColumnNames(xColumns,xMetaData); + aSql.append(generateColumnNames(xColumns,xMetaData)); switch(nDeleteRule) { case KeyRule::CASCADE: - aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + aSql.append(::rtl::OUString::createFromAscii(" ON DELETE CASCADE ")); break; case KeyRule::RESTRICT: - aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + aSql.append(::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ")); break; case KeyRule::SET_NULL: - aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + aSql.append(::rtl::OUString::createFromAscii(" ON DELETE SET NULL ")); break; case KeyRule::SET_DEFAULT: - aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + aSql.append(::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ")); break; default: ; @@ -349,13 +355,13 @@ namespace if ( aSql.getLength() ) { - if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) ) - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + if ( aSql.charAt(aSql.getLength()-1) == ',' ) + aSql.setCharAt(aSql.getLength()-1,')'); else - aSql += ::rtl::OUString::createFromAscii(")"); + aSql.appendAscii(")"); } - return aSql; + return aSql.makeStringAndClear(); } // ----------------------------------------------------------------------------- @@ -364,7 +370,7 @@ namespace const ::rtl::OUString& _sCreatePattern) { ::rtl::OUString aSql = ::dbtools::createStandardCreateStatement(descriptor,_xConnection,_sCreatePattern); - ::rtl::OUString sKeyStmt = ::dbtools::createStandardKeyStatement(descriptor,_xConnection); + const ::rtl::OUString sKeyStmt = ::dbtools::createStandardKeyStatement(descriptor,_xConnection); if ( sKeyStmt.getLength() ) aSql += sKeyStmt; else @@ -603,7 +609,7 @@ Reference< XTablesSupplier> getDataDefinitionByURLAndConnection( // if we don't get the catalog from the original driver we have to try them all. if ( !xTablesSup.is() ) - { + { // !TODO: Why? Reference< XEnumerationAccess> xEnumAccess( xManager, UNO_QUERY_THROW ); Reference< XEnumeration > xEnum( xEnumAccess->createEnumeration(), UNO_QUERY_THROW ); while ( xEnum.is() && xEnum->hasMoreElements() && !xTablesSup.is() ) diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index a9c942ec9cb2..ee335705e651 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -85,6 +85,7 @@ EXCEPTIONSFILES=\ $(SLO)$/filtermanager.obj \ $(SLO)$/parameters.obj \ $(SLO)$/ParamterSubstitution.obj \ + $(SLO)$/DriversConfig.obj \ $(SLO)$/formattedcolumnvalue.obj \ $(SLO)$/warningscontainer.obj diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index d45a7ac849a3..b2a093753804 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -54,6 +54,7 @@ #include #include #include "connectivity/ParameterCont.hxx" +#include //........................................................................ namespace dbtools @@ -394,24 +395,24 @@ namespace dbtools // did we find links where the detail field refers to a detail column (instead of a parameter name)? if ( !aAdditionalFilterComponents.empty() ) { + const static ::rtl::OUString s_sAnd( RTL_CONSTASCII_USTRINGPARAM( " AND " ) ); // build a conjunction of all the filter components - ::rtl::OUString sAdditionalFilter; + ::rtl::OUStringBuffer sAdditionalFilter; for ( ::std::vector< ::rtl::OUString >::const_iterator aComponent = aAdditionalFilterComponents.begin(); aComponent != aAdditionalFilterComponents.end(); ++aComponent ) { - ::rtl::OUString sBracketed( RTL_CONSTASCII_USTRINGPARAM( "( " ) ); - sBracketed += *aComponent; - sBracketed += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " )" ) ); - if ( sAdditionalFilter.getLength() ) - sAdditionalFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " AND " ) ); - sAdditionalFilter += sBracketed; + sAdditionalFilter.append(s_sAnd); + + sAdditionalFilter.appendAscii("( ",((sal_Int32)(sizeof("( ")-1))); + sAdditionalFilter.append(*aComponent); + sAdditionalFilter.appendAscii(" )",((sal_Int32)(sizeof(" )")-1))); } // now set this filter at the 's filter manager - _rFilterManager.setFilterComponent( FilterManager::fcLinkFilter, sAdditionalFilter ); + _rFilterManager.setFilterComponent( FilterManager::fcLinkFilter, sAdditionalFilter.makeStringAndClear() ); _rColumnsInLinkDetails = true; } @@ -1119,3 +1120,4 @@ namespace dbtools //........................................................................ } // namespace frm //........................................................................ + diff --git a/connectivity/source/dbtools/makefile.mk b/connectivity/source/dbtools/makefile.mk index 908d38c92e03..060ff6c55487 100644 --- a/connectivity/source/dbtools/makefile.mk +++ b/connectivity/source/dbtools/makefile.mk @@ -65,6 +65,7 @@ SHL1STDLIBS=\ $(SALLIB) \ $(JVMACCESSLIB) \ $(UNOTOOLSLIB) \ + $(TOOLSLIB) \ $(COMPHELPERLIB) \ $(I18NISOLANGLIB) diff --git a/connectivity/source/drivers/adabas/adabas.xcu b/connectivity/source/drivers/adabas/adabas.xcu new file mode 100755 index 000000000000..0648d25cebe6 --- /dev/null +++ b/connectivity/source/drivers/adabas/adabas.xcu @@ -0,0 +1,128 @@ + + + + + + + com.sun.star.comp.sdbcx.adabas.ODriver + + + Adabas D + + + + + false + + + + + 20 + + + + + 20 + + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk index 59f3238b4fdc..09b2936e1c7d 100644 --- a/connectivity/source/drivers/adabas/makefile.mk +++ b/connectivity/source/drivers/adabas/makefile.mk @@ -42,8 +42,8 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/version.mk +.INCLUDE : $(PRJ)$/makefile.pmk +.INCLUDE : $(PRJ)$/version.mk .IF "$(SYSTEM_ODBC_HEADERS)" == "YES" CFLAGS+=-DSYSTEM_ODBC_HEADERS @@ -104,9 +104,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) DEF1EXPORTFILE= exports.dxp - # --- Targets ---------------------------------- -.INCLUDE : target.mk - +.INCLUDE : $(PRJ)$/target.pmk \ No newline at end of file diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu new file mode 100755 index 000000000000..949d6fb86a19 --- /dev/null +++ b/connectivity/source/drivers/ado/ado.xcu @@ -0,0 +1,242 @@ + + + + + + + com.sun.star.comp.sdbc.ado.ODriver + + + ADO + + + + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + + com.sun.star.comp.sdbc.ado.ODriver + + + Microsoft Access + + + + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + false + + + + + true + + + + + true + + + + + true + + + + + application/msaccess + + + + + mdb + + + + + 3 + + + + + + + sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=* + + + Microsoft Access 2007 + + + + + + + + + + + diff --git a/connectivity/source/drivers/ado/makefile.mk b/connectivity/source/drivers/ado/makefile.mk index 1aace34e4de6..b453c528e127 100644 --- a/connectivity/source/drivers/ado/makefile.mk +++ b/connectivity/source/drivers/ado/makefile.mk @@ -28,7 +28,6 @@ # for a copy of the LGPLv3 License. # #************************************************************************* -.IF "$(GUI)"=="WNT" PRJ=..$/..$/.. PRJINC=..$/.. @@ -43,9 +42,10 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk .INCLUDE : $(PRJ)$/version.mk +.INCLUDE : $(PRJ)$/makefile.pmk +.IF "$(GUI)"=="WNT" # --- Files ------------------------------------- EXCEPTIONSFILES= \ @@ -109,9 +109,10 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) DEF1EXPORTFILE= exports.dxp -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - +.ELSE +dummy: + @echo "Nothing to build for GUI $(GUI)" .ENDIF # "$(GUI)"=="WNT" +# --- Targets ---------------------------------- +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/calc/calc.xcu b/connectivity/source/drivers/calc/calc.xcu new file mode 100755 index 000000000000..7260341946f1 --- /dev/null +++ b/connectivity/source/drivers/calc/calc.xcu @@ -0,0 +1,66 @@ + + + + + + + com.sun.star.comp.sdbc.calc.ODriver + + + Spreadsheet + + + + + true + + + + + + + true + + + + + true + + + + + application/vnd.oasis.opendocument.spreadsheet + + + + + + diff --git a/connectivity/source/drivers/calc/makefile.mk b/connectivity/source/drivers/calc/makefile.mk index 08d83423638d..620bcd6a8eee 100644 --- a/connectivity/source/drivers/calc/makefile.mk +++ b/connectivity/source/drivers/calc/makefile.mk @@ -42,7 +42,7 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk @@ -94,6 +94,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 1c5210bfcdc6..a6ee377e586e 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2785,13 +2785,13 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) if ( bIsText ) { // char cChar; - ::rtl::OUString aStr; + ::rtl::OUStringBuffer aStr; while ( nLength > STRING_MAXLEN ) { ByteString aBStr; aBStr.Expand(STRING_MAXLEN); m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN); - aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); + aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding)); nLength -= STRING_MAXLEN; } if ( nLength > 0 ) @@ -2800,12 +2800,10 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) aBStr.Expand(static_cast(nLength)); m_pMemoStream->Read(aBStr.AllocBuffer(static_cast(nLength)),nLength); // aBStr.ReleaseBufferAccess(); - - aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding); - + aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding)); } if ( aStr.getLength() ) - aVariable = aStr; + aVariable = aStr.makeStringAndClear(); } // if ( bIsText ) else { diff --git a/connectivity/source/drivers/dbase/dbase.xcu b/connectivity/source/drivers/dbase/dbase.xcu new file mode 100755 index 000000000000..e981a56a34d2 --- /dev/null +++ b/connectivity/source/drivers/dbase/dbase.xcu @@ -0,0 +1,98 @@ + + + + + + + com.sun.star.comp.sdbc.dbase.ODriver + + + dBASE + + + + + + + + + + false + + + + + false + + + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + application/dbase + + + + + + diff --git a/connectivity/source/drivers/dbase/makefile.mk b/connectivity/source/drivers/dbase/makefile.mk index 7a827b86d46f..37a88ef47674 100644 --- a/connectivity/source/drivers/dbase/makefile.mk +++ b/connectivity/source/drivers/dbase/makefile.mk @@ -41,7 +41,7 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk # --- Files ------------------------------------- @@ -128,6 +128,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/evoab/LCatalog.cxx b/connectivity/source/drivers/evoab/LCatalog.cxx new file mode 100644 index 000000000000..713af210ac38 --- /dev/null +++ b/connectivity/source/drivers/evoab/LCatalog.cxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LCatalog.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + + +#include "LCatalog.hxx" +#include "LConnection.hxx" +#include "LTables.hxx" +#include +#include + +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::evoab; +// ------------------------------------------------------------------------- +OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) : file::OFileCatalog(_pCon) +{ +} +// ------------------------------------------------------------------------- +void OEvoabCatalog::refreshTables() +{ + TStringVector aVector; + Sequence< ::rtl::OUString > aTypes; + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(3)); + } + if(m_pTables) + m_pTables->reFill(aVector); + else + m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/evoab/LCatalog.hxx b/connectivity/source/drivers/evoab/LCatalog.hxx new file mode 100644 index 000000000000..e539db3a8fc3 --- /dev/null +++ b/connectivity/source/drivers/evoab/LCatalog.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LCatalog.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LCATALOG_HXX_ +#define _CONNECTIVITY_EVOAB_LCATALOG_HXX_ + +#include "file/FCatalog.hxx" + +namespace connectivity +{ + namespace evoab + { + class OEvoabConnection; + class OEvoabCatalog : public file::OFileCatalog + { + public: + virtual void refreshTables(); + + public: + OEvoabCatalog(OEvoabConnection* _pCon); + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LCATALOG_HXX_ + diff --git a/connectivity/source/drivers/evoab/LColumnAlias.cxx b/connectivity/source/drivers/evoab/LColumnAlias.cxx new file mode 100644 index 000000000000..30b94e2e20c9 --- /dev/null +++ b/connectivity/source/drivers/evoab/LColumnAlias.cxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LColumnAlias.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LColumnAlias.hxx" +#include "LDriver.hxx" +#include +#include +#include "LConfigAccess.hxx" + +using namespace ::connectivity; +using namespace ::connectivity::evoab; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; + +static const ::rtl::OUString sProgrammaticNames[] = +{ + ::rtl::OUString::createFromAscii("FirstName"), + ::rtl::OUString::createFromAscii("LastName"), + ::rtl::OUString::createFromAscii("DisplayName"), + ::rtl::OUString::createFromAscii("NickName"), + ::rtl::OUString::createFromAscii("PrimaryEmail"), + ::rtl::OUString::createFromAscii("SecondEmail"), + ::rtl::OUString::createFromAscii("PreferMailFormat"), + ::rtl::OUString::createFromAscii("WorkPhone"), + ::rtl::OUString::createFromAscii("HomePhone"), + ::rtl::OUString::createFromAscii("FaxNumber"), + ::rtl::OUString::createFromAscii("PagerNumber"), + ::rtl::OUString::createFromAscii("CellularNumber"), + ::rtl::OUString::createFromAscii("HomeAddress"), + ::rtl::OUString::createFromAscii("HomeAddress2"), + ::rtl::OUString::createFromAscii("HomeCity"), + ::rtl::OUString::createFromAscii("HomeState"), + ::rtl::OUString::createFromAscii("HomeZipCode"), + ::rtl::OUString::createFromAscii("HomeCountry"), + ::rtl::OUString::createFromAscii("WorkAddress"), + ::rtl::OUString::createFromAscii("WorkAddress2"), + ::rtl::OUString::createFromAscii("WorkCity"), + ::rtl::OUString::createFromAscii("WorkState"), + ::rtl::OUString::createFromAscii("WorkZipCode"), + ::rtl::OUString::createFromAscii("WorkCountry"), + ::rtl::OUString::createFromAscii("JobTitle"), + ::rtl::OUString::createFromAscii("Department"), + ::rtl::OUString::createFromAscii("Company"), + ::rtl::OUString::createFromAscii("WebPage1"), + ::rtl::OUString::createFromAscii("WebPage2"), + ::rtl::OUString::createFromAscii("BirthYear"), + ::rtl::OUString::createFromAscii("BirthMonth"), + ::rtl::OUString::createFromAscii("BirthDay"), + ::rtl::OUString::createFromAscii("Notes") +}; +//------------------------------------------------------------------------------ +OColumnAlias::OColumnAlias() +{ + // Initialise m_aAlias with the default values from sProgrammaticNames. + initialise(); + + // Initialise m_aAlias map with the default values from sProgrammaticNames. + setAliasMap(); +} +//------------------------------------------------------------------ +OColumnAlias::~OColumnAlias() +{ +} +//------------------------------------------------------------------ +void OColumnAlias::initialise() +{ + m_aAlias.reserve( END - FIRSTNAME + 1 ); + for (sal_Int32 i(FIRSTNAME); i < END; ++i) + { + m_aAlias.push_back(sProgrammaticNames[i]); + m_aHeadLineNames.push_back(sProgrammaticNames[i]); + } + + return; +} +//------------------------------------------------------------------ +void OColumnAlias::setAlias(const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) +{ + OSL_TRACE("OColumnAlias::setAlias()entered"); + + // open our driver settings config node + + // the config path for our own driver's settings + Reference< XPropertySet > xEvoDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() ); + //Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, mozab::OConnection::getDriverImplementationName() ); + Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver") ); + if ( xEvoDriverNode.is() && xMozDriverNode.is() ) + { + try + { + //============================================================= + Reference< XNameAccess > xEvoAliasesNode; + Reference< XNameAccess > xMozAliasesNode; + xEvoDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xEvoAliasesNode; + xMozDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xMozAliasesNode; + OSL_ENSURE( xEvoAliasesNode.is(), "OColumnAlias::setAlias: missing the evolution aliases node!" ); + OSL_ENSURE( xMozAliasesNode.is(), "OColumnAlias::setAlias: missing the mozilla aliases node!" ); + + // this is a set of string nodes + Sequence< ::rtl::OUString > aColumnProgrammaticNames; + //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getElementNames()"); + if ( xEvoAliasesNode.is() ) + aColumnProgrammaticNames = xEvoAliasesNode->getElementNames(); + //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getElementNames()"); + + //============================================================= + // travel through all the set elements + const ::rtl::OUString* pProgrammaticNames = aColumnProgrammaticNames.getConstArray(); + const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aColumnProgrammaticNames.getLength(); + ::rtl::OUString sAssignedAlias; + ::rtl::OUString sHeadLineName; + + for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames ) + { + //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammaticNames = %s\n", ((OUtoCStr(*pProgrammaticNames)) ? (OUtoCStr(*pProgrammaticNames)):("NULL")) ); + OSL_ENSURE( m_aAliasMap.end() != m_aAliasMap.find( *pProgrammaticNames ), + "OColumnAlias::setAlias: found an invalid programmtic name!" ); + // if this asserts, somebody stored a programmatic name in the configuration + // which is not allowed (i.e. not in the list of known programmatics). + //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getByName()"); + +#if OSL_DEBUG_LEVEL > 0 + sal_Bool bExtractionSuccess = +#endif + xMozAliasesNode->getByName( *pProgrammaticNames) >>= sAssignedAlias; + OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid mozilla config data!" ); +#if OSL_DEBUG_LEVEL > 0 + bExtractionSuccess = +#endif + xEvoAliasesNode->getByName( *pProgrammaticNames) >>= sHeadLineName; + OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid evolution config data!" ); + //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getByName()"); + + // normalize in case the config data is corrupted + // (what we really don't need is an empty alias ...) + if ( 0 == sAssignedAlias.getLength() ) + sAssignedAlias = *pProgrammaticNames; + if ( 0 == sHeadLineName.getLength() ) + sHeadLineName = *pProgrammaticNames; + //OSL_TRACE("OColumnAlias::setAlias()::sAssignedAlias = %s\n", ((OUtoCStr(sAssignedAlias)) ? (OUtoCStr(sAssignedAlias)):("NULL")) ); + //OSL_TRACE("OColumnAlias::setAlias()::sHeadLineName = %s\n", ((OUtoCStr(sHeadLineName)) ? (OUtoCStr(sHeadLineName)):("NULL")) ); + + //============================================================= + // check the value + // look up the programmatic indicated by pProgrammaticNames in the known programmatics + const ::rtl::OUString* pProgrammatic = sProgrammaticNames + FIRSTNAME; + const ::rtl::OUString* pProgrammaticEnd = sProgrammaticNames + END; + + OSL_ENSURE( (sal_Int32)m_aAlias.size() == pProgrammaticEnd - pProgrammatic, + "OColumnAlias::setAlias: aliases vector not yet initialized!" ); + + // the destination where we want to remember the alias + ::std::vector< ::rtl::OUString >::iterator aAlias = m_aAlias.begin(); + ::std::vector< ::rtl::OUString >::iterator aHeadLineName = m_aHeadLineNames.begin(); + + for ( ; pProgrammatic < pProgrammaticEnd; ++pProgrammatic, ++aAlias, ++aHeadLineName ) + { + //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammatic = %s\n", ((OUtoCStr(*pProgrammatic)) ? (OUtoCStr(*pProgrammatic)):("NULL")) ); + if ( pProgrammaticNames->equals( *pProgrammatic ) ) + { + // add alias to the vector + *aAlias = sAssignedAlias; + *aHeadLineName = sHeadLineName; + break; + } + } + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "OColumnAlias::setAlias: could not read my driver's configuration data!" ); + } + } + + // Initialise m_aAliasMap. + setAliasMap(); + + return; +} +//------------------------------------------------------------------ +const ::std::vector< ::rtl::OUString> & OColumnAlias::getAlias() const +{ + return m_aAlias; +} +//------------------------------------------------------------------ +const ::std::map< ::rtl::OUString, ::rtl::OUString> & OColumnAlias::getAliasMap() const +{ + return m_aAliasMap; +} +//------------------------------------------------------------------ +void OColumnAlias::setAliasMap() +{ + // Fill the map with the values of m_aAlias + // and the sProgrammaticNames array. + for (sal_Int32 i(FIRSTNAME); i < END; ++i) { + m_aAliasMap[m_aAlias[i]] = m_aHeadLineNames[i]; + //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAlias[i] = %s\n", ((OUtoCStr(m_aAlias[i])) ? (OUtoCStr(m_aAlias[i])):("NULL")) ); + //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAliasMap[m_aAlias[i]] = %s\n", ((OUtoCStr(m_aAliasMap[m_aAlias[i]])) ? (OUtoCStr(m_aAliasMap[m_aAlias[i]])):("NULL")) ); + } + + return; +} +//------------------------------------------------------------------ diff --git a/connectivity/source/drivers/evoab/LColumnAlias.hxx b/connectivity/source/drivers/evoab/LColumnAlias.hxx new file mode 100644 index 000000000000..c91931d121bf --- /dev/null +++ b/connectivity/source/drivers/evoab/LColumnAlias.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LColumnAlias.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ +#define _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ + +#include + +#include +#include +#include + +namespace connectivity +{ + namespace evoab + { + typedef enum { + FIRSTNAME = 0, + LASTNAME, + DISPLAYNAME, + NICKNAME, + PRIMARYEMAIL, + SECONDEMAIL, + PREFERMAILFORMAT, + WORKPHONE, + HOMEPHONE, + FAXNUMBER, + PAGERNUMBER, + CELLULARNUMBER, + HOMEADDRESS, + HOMEADDRESS2, + HOMECITY, + HOMESTATE, + HOMEZIPCODE, + HOMECOUNTRY, + WORKADDRESS, + WORKADDRESS2, + WORKCITY, + WORKSTATE, + WORKZIPCODE, + WORKCOUNTRY, + JOBTITLE, + DEPARTMENT, + COMPANY, + WEBPAGE1, + WEBPAGE2, + BIRTHYEAR, + BIRTHMONTH, + BIRTHDAY, + NOTES, + END + } ProgrammaticName; + + class OColumnAlias + { + /** + * m_Alias holds aliases for the evolution addressbook + * column names. This member gets initialised during + * creation of the connection to the driver. + * m_aAlias initialises m_aAliasMap which then can be + * used to find the corresponding programmatic name + * when an alias is used as a query attribute. Mozilla + * expects programmatic names from its clients. + * + * m_aAlias: vector of aliases used to initialise m_aAliasMap. + * m_AliasMap: map of {alias, programmaticname} pairs. + * + */ + private: + ::std::vector< ::rtl::OUString> m_aAlias; + ::std::vector< ::rtl::OUString> m_aHeadLineNames; + ::std::map< ::rtl::OUString, ::rtl::OUString> m_aAliasMap; + protected: + ::osl::Mutex m_aMutex; + public: + void initialise(void); + const ::std::vector< ::rtl::OUString> & getAlias(void) const; + const ::std::map< ::rtl::OUString, ::rtl::OUString> & getAliasMap(void) const; + void setAlias(const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > &); + private: + void setAliasMap(void); + public: + OColumnAlias(void); + ~OColumnAlias(void); + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ diff --git a/connectivity/source/drivers/evoab/LColumns.cxx b/connectivity/source/drivers/evoab/LColumns.cxx new file mode 100644 index 000000000000..9608c8efd384 --- /dev/null +++ b/connectivity/source/drivers/evoab/LColumns.cxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LColumns.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "LColumns.hxx" +#include "LTable.hxx" +#include "connectivity/sdbcx/VColumn.hxx" + +using namespace connectivity::evoab; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + + +sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName) +{ + + OEvoabTable* pTable = (OEvoabTable*)m_pTable; + ::vos::ORef aCols = pTable->getTableColumns(); + OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); + sdbcx::ObjectType xRet; + if(aIter != aCols->get().end()) + xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); + return xRet; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/evoab/LColumns.hxx b/connectivity/source/drivers/evoab/LColumns.hxx new file mode 100644 index 000000000000..457f319ca7b1 --- /dev/null +++ b/connectivity/source/drivers/evoab/LColumns.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LColumns.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ +#define _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ + +#include "file/FColumns.hxx" + +namespace connectivity +{ + namespace evoab + { + class OEvoabColumns : public file::OColumns + { + protected: + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + public: + OEvoabColumns(file::OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector + ) : file::OColumns(_pTable,_rMutex,_rVector) + {} + + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ + diff --git a/connectivity/source/drivers/evoab/LConfigAccess.cxx b/connectivity/source/drivers/evoab/LConfigAccess.cxx new file mode 100644 index 000000000000..9df502d35d70 --- /dev/null +++ b/connectivity/source/drivers/evoab/LConfigAccess.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LConfigAccess.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LConfigAccess.hxx" +#include "LDriver.hxx" +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#include "LDebug.hxx" +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; + +//......................................................................... +namespace connectivity +{ + namespace evoab + { + //----------------------------------------------------------------- + Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName ) + { + OSL_TRACE("createDriverConfigNode()entered"); + + Reference< XPropertySet > xNode; + try + { + //============================================================= + // create the config provider + Reference< XMultiServiceFactory > xConfigProvider( + _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ), + UNO_QUERY + ); + OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" ); + + if ( xConfigProvider.is() ) + { + ::rtl::OUString sCompleteNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Office.DataAccess/DriverSettings/" ); + sCompleteNodePath += _sDriverImplementationName; + //sCompleteNodePath += OEvoabConnection::getDriverImplementationName(); + //sCompleteNodePath += ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver"); + EVO_TRACE_STRING("createDriverConfigNode()::sCompleteNodePath = %s\n", sCompleteNodePath ); + + //========================================================= + // arguments for creating the config access + Sequence< Any > aArguments(2); + // the path to the node to open + aArguments[0] <<= PropertyValue( + ::rtl::OUString::createFromAscii( "nodepath"), + 0, + makeAny( sCompleteNodePath ), + PropertyState_DIRECT_VALUE + ); + // the depth: -1 means unlimited + aArguments[1] <<= PropertyValue( + ::rtl::OUString::createFromAscii( "depth"), + 0, + makeAny( (sal_Int32)-1 ), + PropertyState_DIRECT_VALUE + ); + + //========================================================= + // create the access + Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments( + ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ), + aArguments + ); + OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" ); + + xNode = xNode.query( xAccess ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "createDriverConfigNode: caught an exception while accessing the driver's config node!" ); + } + + // outta here + return xNode; + } + + //----------------------------------------------------------------- + namespace + { + // a private helper to accessing the point where we store the reference + // to the factory + Reference< XMultiServiceFactory >& accessFactoryStorage( ) + { + static Reference< XMultiServiceFactory > xEvoabServiceFactory; + return xEvoabServiceFactory; + } + } + + //----------------------------------------------------------------- + void setEvoabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory ) + { + accessFactoryStorage( ) = _rxFactory; + } + + //----------------------------------------------------------------- + const Reference< XMultiServiceFactory >& getEvoabServiceFactory( ) + { + return accessFactoryStorage( ); + } + + //----------------------------------------------------------------- + ::rtl::OUString getFullPathExportingCommand( Reference< XMultiServiceFactory > _rxORB ) + { + ::rtl::OUString sFullPathExportingCommand; + + //Reference< XMultiServiceFactory > xFactory = getEvoabServiceFactory(); + //OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" ); + OSL_ENSURE( _rxORB.is(), "getFullPathExportingCommand: invalid service factory!" ); + if ( _rxORB.is() ) + { + try + { + Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() ); + Reference< XPropertySet > xEvoPrefsNode; + if ( xDriverNode.is() ) + xDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii( "EvolutionPreferences" ) ) >>= xEvoPrefsNode; + OSL_ENSURE( xEvoPrefsNode.is(), "getFullPathExportingCommand: could not access the node for the evolution preferences!" ); + if ( xEvoPrefsNode.is() ) + xEvoPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii( "FullPathExportingCommand" ) ) >>= sFullPathExportingCommand; + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "getFullPathExportingCommand: caught an exception!" ); + } + } + return sFullPathExportingCommand; + } + } +} + +//......................................................................... diff --git a/connectivity/source/drivers/evoab/LConfigAccess.hxx b/connectivity/source/drivers/evoab/LConfigAccess.hxx new file mode 100644 index 000000000000..9df43ef3226b --- /dev/null +++ b/connectivity/source/drivers/evoab/LConfigAccess.hxx @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LConfigAccess.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ +#define _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ + +// This is the extended version (for use on the SO side of the driver) of MConfigAccess +// (which is for use on the mozilla side only) + +#include +#include + +namespace connectivity +{ + namespace evoab + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName ); + ::rtl::OUString getFullPathExportingCommand( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB ); + } +} +#endif // _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ diff --git a/connectivity/source/drivers/evoab/LConnection.cxx b/connectivity/source/drivers/evoab/LConnection.cxx new file mode 100644 index 000000000000..383354d8ff5f --- /dev/null +++ b/connectivity/source/drivers/evoab/LConnection.cxx @@ -0,0 +1,270 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LConnection.cxx,v $ + * $Revision: 1.12.56.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LConnection.hxx" +#include "LDatabaseMetaData.hxx" +#include "LCatalog.hxx" +#include +#include +#include "LPreparedStatement.hxx" +#include "LStatement.hxx" +#include +#include +#include +#include +#include +#include +#include "LDebug.hxx" +#include "diagnose_ex.h" +#include +#include +#include "resource/common_res.hrc" + +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace vos; + +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; + +::rtl::OUString implGetExceptionMsg( Exception& e, const ::rtl::OUString& aExceptionType_ ) +{ + ::rtl::OUString aExceptionType = aExceptionType_; + if( aExceptionType.getLength() == 0 ) + aExceptionType = ::rtl::OUString( ::rtl::OUString::createFromAscii("Unknown" ) ); + + ::rtl::OUString aTypeLine( ::rtl::OUString::createFromAscii("\nType: " ) ); + aTypeLine += aExceptionType; + + ::rtl::OUString aMessageLine( ::rtl::OUString::createFromAscii("\nMessage: " ) ); + aMessageLine += ::rtl::OUString( e.Message ); + + ::rtl::OUString aMsg(aTypeLine); + aMsg += aMessageLine; + return aMsg; +} + + // Exception type unknown +::rtl::OUString implGetExceptionMsg( Exception& e ) +{ + ::rtl::OUString aMsg = implGetExceptionMsg( e, ::rtl::OUString() ); + return aMsg; +} + +// -------------------------------------------------------------------------------- +OEvoabConnection::OEvoabConnection(OEvoabDriver* _pDriver) : OConnection(_pDriver) + ,m_bHeaderLine(sal_True) + ,m_cFieldDelimiter(',') + ,m_cStringDelimiter('"') + ,m_cDecimalDelimiter('.') + ,m_cThousandDelimiter(' ') +{ + // Initialise m_aColumnAlias. + m_aColumnAlias.setAlias(_pDriver->getFactory()); +} +//----------------------------------------------------------------------------- +OEvoabConnection::~OEvoabConnection() +{ +} + +// XServiceInfo +// -------------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OEvoabConnection, "com.sun.star.sdbc.drivers.evoab.Connection", "com.sun.star.sdbc.Connection") + +//----------------------------------------------------------------------------- +void OEvoabConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) +{ + osl_incrementInterlockedCount( &m_refCount ); + EVO_TRACE_STRING("OEvoabConnection::construct()::url = %s\n", url ); + + + ::rtl::OUString aCLICommand = getDriver()->getEvoab_CLI_EffectiveCommand(); + ::rtl::OUString aWorkingDirPath = getDriver()->getWorkingDirPath(); + ::rtl::OUString aArg1 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS()); + ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX()); + aArg2 += aWorkingDirPath; + aArg2 += getDriver()->getEvoFolderListFileName(); + OArgumentList aArgs(2,&aArg1,&aArg2); + + EVO_TRACE_STRING("OEvoabConnection::construct()::aCLICommand = %s\n", aCLICommand ); + EVO_TRACE_STRING("OEvoabConnection::construct()::aWorkingDirPath = %s\n", aWorkingDirPath ); + EVO_TRACE_STRING("OEvoabConnection::construct()::aArg1 = %s\n", aArg1 ); + EVO_TRACE_STRING("OEvoabConnection::construct()::aArg2 = %s\n", aArg2 ); + OProcess aApp( aCLICommand,aWorkingDirPath); + OSL_VERIFY_EQUALS( + aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs), + OProcess::E_None, + "Error at execute evolution-addressbook-export to get VCards"); + + + Sequence aDriverParam; + ::std::vector aParam; + + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("EnableSQL92Check"), 0, Any(), PropertyState_DIRECT_VALUE)); + ::dbtools::OCharsetMap aLookupIanaName; + ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(RTL_TEXTENCODING_UTF8); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("CharSet"), 0, + makeAny((*aLookup).getIanaName()), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("Extension"), 0, makeAny(getDriver()->getFileExt()), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("HeaderLine"), 0, makeAny(m_bHeaderLine), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("FieldDelimiter"), 0, makeAny(::rtl::OUString(&m_cFieldDelimiter,1)), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("StringDelimiter"), 0, makeAny(::rtl::OUString(&m_cStringDelimiter,1)), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("DecimalDelimiter"), 0, makeAny(::rtl::OUString(&m_cDecimalDelimiter,1)), PropertyState_DIRECT_VALUE)); + aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("ThousandDelimiter"), 0, makeAny(::rtl::OUString(&m_cThousandDelimiter,1)), PropertyState_DIRECT_VALUE)); + + // build a new parameter sequence from the original parameters, appended by the new parameters from above + PropertyValue *pParams = aParam.empty() ? 0 : &aParam[0]; + aDriverParam = ::comphelper::concatSequences( + info, + Sequence< PropertyValue >( pParams, aParam.size() ) + ); + + // transform "sdbc:address:evolution" part of URL to "sdbc:flat:file:///..." + // + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aAddrbookURI(url.copy(nLen+1)); + // Get Scheme + nLen = aAddrbookURI.indexOf(':'); + ::rtl::OUString aAddrbookScheme; + if ( nLen == -1 ) + { + // There isn't any subschema: - but could be just subschema + if ( aAddrbookURI.getLength() > 0 ) + { + aAddrbookScheme= aAddrbookURI; + } + else + { + OSL_TRACE( "No subschema given!!!\n"); + throwGenericSQLException(STR_URI_SYNTAX_ERROR ,*this); + } + } + else + { + aAddrbookScheme = aAddrbookURI.copy(0, nLen); + } + + EVO_TRACE_STRING("OEvoabConnection::construct()::URI = %s\n", aAddrbookURI ); + EVO_TRACE_STRING("OEvoabConnection::construct()::Scheme = %s\n", aAddrbookScheme ); + + // + // Now we have a URI convert it to a Evolution CLI flat file URI + // + // The Mapping being used is: + // + // * for Evolution + // "sdbc:address:evolution:" -> "sdbc:flat:file:///(file path generated) + + rtl::OUString aEvoFlatURI; + if ( aAddrbookScheme.compareToAscii( OEvoabDriver::getSDBC_SCHEME_EVOLUTION() ) == 0 ) + { + aEvoFlatURI = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "sdbc:flat:" )); + } + + + aEvoFlatURI += getDriver()->getWorkingDirURL(); + EVO_TRACE_STRING("OEvoabConnection::construct()::m_aEvoFlatURI = %s\n", aEvoFlatURI ); + //setURL(aEvoFlatURI); + m_aEvoFlatURI = aEvoFlatURI; + + osl_decrementInterlockedCount( &m_refCount ); + OConnection::construct(aEvoFlatURI,aDriverParam); +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OEvoabConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_B::rBHelper.bDisposed); + + + Reference< XDatabaseMetaData > xMetaData = m_xMetaData; + if(!xMetaData.is()) + { + xMetaData = new OEvoabDatabaseMetaData(this); + m_xMetaData = xMetaData; + } + + return xMetaData; +} +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XTablesSupplier > xTab = m_xCatalog; + if(!xTab.is()) + { + OEvoabCatalog *pCat = new OEvoabCatalog(this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_B::rBHelper.bDisposed); + + OEvoabStatement* pStmt = new OEvoabStatement(this); + + Reference< XStatement > xStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_B::rBHelper.bDisposed); + + + OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement(this); + Reference< XPreparedStatement > xStmt = pStmt; + pStmt->construct(sql); + + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this ); + return NULL; +} +// ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LConnection.hxx b/connectivity/source/drivers/evoab/LConnection.hxx new file mode 100644 index 000000000000..e0cd79eb8f78 --- /dev/null +++ b/connectivity/source/drivers/evoab/LConnection.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LConnection.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ +#define _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ + +#include "LDriver.hxx" +#include "file/FConnection.hxx" +#include "LColumnAlias.hxx" + +namespace connectivity +{ + namespace evoab + { + class OEvoabConnection : public file::OConnection + { + private: + OColumnAlias m_aColumnAlias; + sal_Bool m_bHeaderLine; // column names in first row + sal_Unicode m_cFieldDelimiter; // look at the name + sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter + sal_Unicode m_cDecimalDelimiter; // Dezimal-delimiter (Dezimalpoint) + sal_Unicode m_cThousandDelimiter; // + rtl::OUString m_aEvoFlatURI; + + public: + OEvoabConnection(OEvoabDriver* _pDriver); + virtual ~OEvoabConnection(); + + virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); + + // own methods + inline const OEvoabDriver* getDriver() const { return static_cast< const OEvoabDriver* >( m_pDriver ); } + inline sal_Bool isHeaderLine() const { return m_bHeaderLine; } + inline sal_Unicode getFieldDelimiter() const { return m_cFieldDelimiter; } + inline sal_Unicode getStringDelimiter() const { return m_cStringDelimiter; } + inline sal_Unicode getDecimalDelimiter() const { return m_cDecimalDelimiter; } + inline sal_Unicode getThousandDelimiter() const { return m_cThousandDelimiter;} + const OColumnAlias& getColumnAlias() const { return m_aColumnAlias; } + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx new file mode 100644 index 000000000000..5a0f80781d2a --- /dev/null +++ b/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx @@ -0,0 +1,394 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDatabaseMetaData.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LDatabaseMetaData.hxx" +#include "LConnection.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ +#include +#endif +#include +#include "FDatabaseMetaDataResultSet.hxx" +#include +#include +#include +#include "LFolderList.hxx" +#include "connectivity/CommonTools.hxx" +#include +#include +#include +#include +#include + +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#include "LDebug.hxx" +#endif +#include "diagnose_ex.h" + +using namespace ::comphelper; +using namespace connectivity; +using namespace connectivity::evoab; +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::ucb; +using namespace osl; +using namespace vos; + +namespace connectivity +{ + namespace evoab + { + static sal_Int32 const s_nCOLUMN_SIZE = 256; + static sal_Int32 const s_nDECIMAL_DIGITS = 0; + static sal_Int32 const s_nNULLABLE = 1; + static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535; + } +} + +OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon) +{ +} +// ------------------------------------------------------------------------- +OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData() +{ +} +// ------------------------------------------------------------------------- +Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); + Reference< XResultSet > xRef = pResult; + static ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"))); + aRow.push_back(new ORowSetValueDecorator(DataType::CHAR)); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")); + aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR")); + aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); + aRow[3] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); + aRow[2] = new ORowSetValueDecorator(DataType::DATE); + aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME")); + aRow[2] = new ORowSetValueDecorator(DataType::TIME); + aRow[3] = new ORowSetValueDecorator((sal_Int32)8); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[3] = new ORowSetValueDecorator((sal_Int32)19); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL")); + aRow[2] = new ORowSetValueDecorator(DataType::BIT); + aRow[3] = ODatabaseMetaDataResultSet::get1Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL")); + aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); + aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[15] = new ORowSetValueDecorator((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE")); + aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); + aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC")); + aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC); + aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[15] = new ORowSetValueDecorator((sal_Int32)20); + aRows.push_back(aRow); + } + + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( + const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + OSL_TRACE("OEvoabDatabaseMetaData::getColumns()::Entered\n"); + EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::schemaPattern = %s\n", schemaPattern ); + EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::tableNamePattern = %s\n", tableNamePattern ); + EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::columnNamePattern = %s\n", columnNamePattern ); + + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); + if(!xTables.is()) + throw SQLException(); + + Reference< XNameAccess> xNames = xTables->getTables(); + if(!xNames.is()) + throw SQLException(); + + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(19); + aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames()); + const ::rtl::OUString* pTabBegin = aTabNames.getConstArray(); + const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength(); + for(;pTabBegin != pTabEnd;++pTabBegin) + { + if(match(tableNamePattern,*pTabBegin,'\0')) + { + Reference< XColumnsSupplier> xTable; + ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin)); + aRow[3] = new ORowSetValueDecorator(*pTabBegin); + + Reference< XNameAccess> xColumns = xTable->getColumns(); + if(!xColumns.is()) + throw SQLException(); + + Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); + + const ::rtl::OUString* pBegin = aColNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); + Reference< XPropertySet> xColumn; + for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i) + { + if(match(columnNamePattern,*pBegin,'\0')) + { + aRow[4] = new ORowSetValueDecorator(*pBegin); + + ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); + OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); + aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); + aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); + aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); + aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); + aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); + aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); + + switch((sal_Int32)aRow[5]->getValue()) + { + case DataType::CHAR: + case DataType::VARCHAR: + aRow[16] = new ORowSetValueDecorator((sal_Int32)254); + break; + case DataType::LONGVARCHAR: + aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); + break; + default: + aRow[16] = new ORowSetValueDecorator((sal_Int32)0); + } + aRow[17] = new ORowSetValueDecorator(i); + switch(sal_Int32(aRow[11]->getValue())) + { + case ColumnValue::NO_NULLS: + aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); + break; + case ColumnValue::NULLABLE: + aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES")); + break; + default: + aRow[18] = new ORowSetValueDecorator(::rtl::OUString()); + } + aRows.push_back(aRow); + } + } + } + } + + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); + Reference< XResultSet > xRef = pResult; + pResult->setRows(aRows); + + return xRef; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:flat:")) + m_pConnection->getURL(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::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(ODatabaseMetaDataResultSet::eTables); + Reference< XResultSet > xRef = pResult; + + // check if any type is given + // when no types are given then we have to return all tables e.g. TABLE + + static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE")); + + sal_Bool bTableFound = sal_True; + sal_Int32 nLength = types.getLength(); + if(nLength) + { + bTableFound = sal_False; + + const ::rtl::OUString* pBegin = types.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + nLength; + for(;pBegin != pEnd;++pBegin) + { + if(*pBegin == aTable) + { + bTableFound = sal_True; + break; + } + } + } + if(!bTableFound) + return xRef; + + OEvoabConnection* pOEvoabConnection = (OEvoabConnection*)m_pConnection; + OEvoabFolderList* pFolderList = new OEvoabFolderList( pOEvoabConnection ); + + + ODatabaseMetaDataResultSet::ORows aRows; + sal_Bool bMoreData = sal_True; + ::rtl::OUString aName, aLocation; + sal_Int32 nCardsCount; + + pFolderList->initializeRow(3); + bMoreData = pFolderList->first(); + OSL_TRACE("OEvoabDatabaseMetaData::getTables()::first %d\n",bMoreData ); + do + { + if(bMoreData) + bMoreData = pFolderList->getRow(); + if(bMoreData) + { + aLocation = pFolderList->getString(1); + aName = pFolderList->getString(2); + nCardsCount = pFolderList->getInt(3); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aLocation = %s\n", aLocation ); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aName = %s\n", aName ); + OSL_TRACE("OEvoabDatabaseMetaData::getTables()::nCardsCount = %d\n", nCardsCount); + + ODatabaseMetaDataResultSet::ORow aRow(3); + aRow.reserve(6); + aRow.push_back(new ORowSetValueDecorator(aName)); + aRow.push_back(new ORowSetValueDecorator(aTable)); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRows.push_back(aRow); + + ::rtl::OUString aWorkingDir = pOEvoabConnection->getDriver()->getWorkingDirPath(); + ::rtl::OUString aCLICommand = pOEvoabConnection->getDriver()->getEvoab_CLI_EffectiveCommand(); + ::rtl::OUString aArg1 = aLocation; + ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX()); + aArg2 += aWorkingDir; + aArg2 += aName; + aArg2 += ::rtl::OUString::createFromAscii("."); + aArg2 += ::rtl::OUString(pOEvoabConnection->getExtension()); + ::rtl::OUString aArg3 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FORMAT()); + + OArgumentList aArgs(3,&aArg1,&aArg2,&aArg3); + + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aCLICommand = %s\n", aCLICommand ); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aWorkingDir = %s\n", aWorkingDir ); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg1 = %s\n", aArg1 ); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg2 = %s\n", aArg2 ); + EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg3 = %s\n", aArg3 ); + + OProcess aApp( aCLICommand,aWorkingDir); + OSL_VERIFY_EQUALS( + aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs), + OProcess::E_None, + "Error at execute evolution-addressbook-exporter to get VCards" ); + + bMoreData = pFolderList->next(); + } + } + while ( bMoreData ); + + delete pFolderList; + pFolderList = NULL; + + pResult->setRows(aRows); + + return xRef; +} diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx new file mode 100644 index 000000000000..bad565d68e54 --- /dev/null +++ b/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDatabaseMetaData.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ +#define _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ + +#include "file/FDatabaseMetaData.hxx" +#include "FDatabaseMetaDataResultSet.hxx" + +namespace connectivity +{ + namespace evoab + { + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class OEvoabDatabaseMetaData : public file::ODatabaseMetaData + { + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + virtual ~OEvoabDatabaseMetaData(); + public: + OEvoabDatabaseMetaData(file::OConnection* _pCon); + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ + diff --git a/connectivity/source/drivers/evoab/LDebug.cxx b/connectivity/source/drivers/evoab/LDebug.cxx new file mode 100644 index 000000000000..64b39f7cea03 --- /dev/null +++ b/connectivity/source/drivers/evoab/LDebug.cxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDebug.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#include "LDebug.hxx" +#endif +#include + +void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString ) +{ + ::rtl::OString sByteStringMessage( _rAsciiString.getStr(), _rAsciiString.getLength(), RTL_TEXTENCODING_ASCII_US ); + if ( !sByteStringMessage.getLength() ) + sByteStringMessage = ""; + OSL_TRACE( _pFormat, sByteStringMessage.getStr() ); +} diff --git a/connectivity/source/drivers/evoab/LDebug.hxx b/connectivity/source/drivers/evoab/LDebug.hxx new file mode 100644 index 000000000000..dc8a64ef796c --- /dev/null +++ b/connectivity/source/drivers/evoab/LDebug.hxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDebug.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#define CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX + +#include + +#ifdef _DEBUG + void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString ); + + #define EVO_TRACE_STRING( pFormat, rAsciiString ) evo_traceStringMessage( pFormat, rAsciiString ) +#else + #define EVO_TRACE_STRING( pFormat, rAsciiString ) (void)(0) +#endif + + +#endif // CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX diff --git a/connectivity/source/drivers/evoab/LDriver.cxx b/connectivity/source/drivers/evoab/LDriver.cxx new file mode 100644 index 000000000000..379dfba4b21e --- /dev/null +++ b/connectivity/source/drivers/evoab/LDriver.cxx @@ -0,0 +1,508 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDriver.cxx,v $ + * $Revision: 1.10.42.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LDriver.hxx" +#include "LConnection.hxx" +#include +#include "connectivity/dbexception.hxx" +#include "LConfigAccess.hxx" +#include +#include "osl/security.hxx" +#include +#include +#include +#include +#include "resource/common_res.hrc" +#include "resource/sharedresources.hxx" +#include "LDebug.hxx" + +using namespace osl; +using namespace connectivity::evoab; +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::ucb; + +// -------------------------------------------------------------------------------- +OEvoabDriver::OEvoabDriver(const Reference< XMultiServiceFactory >& _rxFactory) : OFileDriver(_rxFactory) + ,m_aTempDir(NULL, sal_True) + ,m_aFolderListName(::rtl::OUString::createFromAscii(getEVOAB_FOLDERLIST_FILE_NAME())) + ,m_aVersionName(::rtl::OUString::createFromAscii(getEVOAB_VERSION_FILE_NAME())) + ,m_aFileExt(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(getEVOAB_META_FILE_EXT()))) + ,m_bWorkingDirCreated(sal_False) + ,m_eSupportedEvoVersion( eUnknown ) +{ + m_aEvoab_CLI_FullPathCommand = getFullPathExportingCommand(_rxFactory); + + if ( m_aEvoab_CLI_FullPathCommand.getLength() == 0 ) + m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii(getEVOAB_CLI_FULLPATHCOMMAND()); + if ( m_aEvoab_CLI_FullPathCommand.copy(0,7) != ::rtl::OUString::createFromAscii("file://") && m_aEvoab_CLI_FullPathCommand.copy(0,1) == ::rtl::OUString::createFromAscii("/")) + m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii("file://") + m_aEvoab_CLI_FullPathCommand; + m_aEvoab_CLI_EffectiveCommand = m_aEvoab_CLI_FullPathCommand; + m_aTempDir.EnableKillingFile(); + + EVO_TRACE_STRING("OEvoabDriver::OEvoabDriver()::m_aEvoab_CLI_FullPathCommand = %s", m_aEvoab_CLI_FullPathCommand ); +} +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString OEvoabDriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii(EVOAB_DRIVER_IMPL_NAME); +} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL OEvoabDriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::evoab::OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new OEvoabDriver(_rxFactory)); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if ( ! acceptsURL(url) ) + return NULL; + + OEvoabConnection* pCon = new OEvoabConnection(this); + pCon->construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +namespace +{ + ::rtl::OUString lcl_translateProcessErrorMessage( oslProcessError nProcErr) + { + ::rtl::OUString sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" not executed!.")); + switch (nProcErr) + { + case osl_Process_E_None: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed sucessful!")); + break; + case osl_Process_E_NotFound: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: not found!")); + break; + case osl_Process_E_NoPermission: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: has no permission!")); + break; + case osl_Process_E_TimedOut: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: time out!")); + break; + case osl_Process_E_Unknown: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: unkown reason!")); + break; + case osl_Process_E_InvalidError: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: invalid error!")); + break; + default: + sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: other reason!")); + } + return sProcErr; + } + oslProcessError lcl_execute( const ::rtl::OUString& _rCommand, ::rtl::OUString& _rArgument, + const ::rtl::OUString& _rWorkingDir, oslProcessOption _nOptions, oslFileHandle& /*[out]*/ _hStdOut ) + { + oslProcessError nError = osl_Process_E_None; + + EVO_TRACE_STRING("LDriver.cxx::lcl_execute: command : %s", _rCommand ); + EVO_TRACE_STRING("LDriver.cxx::lcl_execute: argument : %s", _rArgument ); + EVO_TRACE_STRING("LDriver.cxx::lcl_execute: working dir: %s", _rWorkingDir ); + + oslProcess hProcess( 0 ); + + nError = osl_executeProcess_WithRedirectedIO( + _rCommand.pData, + &_rArgument.pData, + 1, + _nOptions, + 0, + _rWorkingDir.pData, + 0, + 0, + &hProcess, + NULL, + &_hStdOut, + NULL + ); + ::rtl::OUString sError = _rCommand + lcl_translateProcessErrorMessage( nError); + EVO_TRACE_STRING( "%s", sError ); + + if ( nError == osl_Process_E_None ) + { + TimeValue aFiveSeconds; + aFiveSeconds.Seconds = 5; + aFiveSeconds.Nanosec = 0; + oslProcessError nWaitForProcessError = osl_joinProcessWithTimeout( hProcess, &aFiveSeconds ); + if ( osl_Process_E_None != nWaitForProcessError ) + { + nError = nWaitForProcessError; + // TODO: kill the running process? + } + osl_freeProcessHandle( hProcess ); + } + return nError; + } +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + sal_Bool bRet; + bRet = sal_False; + // here we have to look if we support this url format + if(acceptsURL_Stat(url)) + { + if ( m_eSupportedEvoVersion != eUnknown ) + return m_eSupportedEvoVersion == eTrue ? sal_True : sal_False; + + if(!m_bWorkingDirCreated) + { + String sTempDirURL = getTempDirURL(); + //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::sTempDirURL = %s", sTempDirURL ); + + ::rtl::OUString aTempDirURL(sTempDirURL); + m_aWorkingDirURL = aTempDirURL; + m_bWorkingDirCreated = sal_True; + } + + ::rtl::OUString aCLICommand = getEvoab_CLI_EffectiveCommand(); + ::rtl::OUString aWorkingDirURL = getWorkingDirURL(); + ::rtl::OUString aArgVersion = ::rtl::OUString::createFromAscii(getEVOAB_CLI_ARG_VERSION()); + + oslFileHandle hStdout = NULL; + oslProcessError nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, 0, hStdout ); + if(nProcErr != osl_Process_E_None) + { + if(doesEvoab_CLI_HavePath()) + aCLICommand = getEvoab_CLI_Command(); + else + aCLICommand = getEvoab_CLI_Path() + getEvoab_CLI_Command(); + nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, osl_Process_SEARCHPATH | osl_Process_HIDDEN, hStdout ); + if ( nProcErr == osl_Process_E_None ) + m_aEvoab_CLI_EffectiveCommand = aCLICommand; + } + + if ( hStdout != NULL ) + { + OSL_ASSERT( hStdout ); + sal_Char pBuffer[256]; + sal_uInt64 nBytesRead; + oslFileError nFileErr = osl_File_E_None; + nFileErr = osl_readFile( hStdout, pBuffer, 256, &nBytesRead); + if ( nFileErr != osl_File_E_None ) + { + ::rtl::OUString sErr = translateFileErrorMessage( nFileErr); + OSL_ENSURE(false, ::rtl::OUStringToOString( sErr, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + ::rtl::OUString aVersionInfo; + if ( nFileErr == osl_File_E_None && nBytesRead > 0 && nBytesRead <= 256) + { + OSL_TRACE("OEvoabDriver::acceptsURL()::osl_readFile(),nBytesRead = %u",nBytesRead); + aVersionInfo = + ::rtl::OUString( ( const sal_Char * )pBuffer, + (sal_Int32)nBytesRead, + RTL_TEXTENCODING_UTF8 ); + EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aVersionInfo = %s", aVersionInfo ); + sal_Int32 nIndex = 0; + sal_Bool bNumRetrieved = sal_False; + ::rtl::OUString aToken; + sal_Int32 aVer[4]; + sal_Int32 i; + for ( i = 0; i < 4; i++ ) + aVer[i] = 0; + do + { + aToken = aVersionInfo.getToken( 0, ' ', nIndex ); + //OSL_TRACE("OEvoabDriver::acceptsURL()::Token:%d", nIndex ); + //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aToken = %s", aToken ); + if( aToken.toChar() >= '0' && aToken.toChar() <= '9' ) + { + bNumRetrieved = sal_True; + sal_Int32 nIndex1 = 0; + ::rtl::OUString aNum; + for(i = 0; i < 4 ; i++) + { + if( nIndex1 >= 0 ) + { + aNum = aToken.getToken( 0, '.', nIndex1); + aVer[i] = aNum.toInt32(); + OSL_TRACE("OEvoabDriver::acceptsURL()::Ver[%u]=%u", i, aVer[i] ); + } + } + } + } + while ( nIndex >= 0 && !bNumRetrieved ); + + if((aVer[0]>1)||(aVer[0]==1 && aVer[1]>3)||(aVer[0]==1 && aVer[1]==3 && aVer[2]>2)||(aVer[0]==1 && aVer[1]==3 && aVer[2]==2 && aVer[3]>=99)) + bRet = sal_True; + else + bRet = sal_False; + } + else + bRet = sal_False; + + osl_closeFile( hStdout ); + } + m_eSupportedEvoVersion = bRet ? eTrue : eFalse; + } + EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::return, return value = %s", ::rtl::OUString::valueOf(bRet) ); + return bRet; +} + + +// -------------------------------------------------------------------------------- +sal_Bool OEvoabDriver::acceptsURL_Stat( const ::rtl::OUString& url ) +{ + + EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", url ); + // Skip 'sdbc:address: part of URL + // + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aAddrbookURI(url.copy(nLen+1)); + + // Get Scheme + nLen = aAddrbookURI.indexOf(':'); + ::rtl::OUString aAddrbookScheme; + if ( nLen == -1 ) + { + // There isn't any subschema: - but could be just subschema + if ( aAddrbookURI.getLength() > 0 ) + aAddrbookScheme= aAddrbookURI; + else if(url == ::rtl::OUString::createFromAscii("sdbc:address:") ) + return sal_True; // special case here + else + return sal_False; + } + else + aAddrbookScheme = aAddrbookURI.copy(0, nLen); + + + EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::URI = %s", aAddrbookURI ); + EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", aAddrbookScheme ); + + return aAddrbookScheme.compareToAscii( getSDBC_SCHEME_EVOLUTION() ) == 0 ; +} +// ------------------------------------------------------------------------- +const rtl::OUString OEvoabDriver::getEvoab_CLI_Command() const +{ + rtl::OUString aEvoab_CLI_Command; + sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/'); + + if ( nLen == -1 ) + aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand; + else + aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand.copy(nLen+1); + + EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Command()::aEvoab_CLI_Command = %s", aEvoab_CLI_Command ); + + return aEvoab_CLI_Command; +} +// ------------------------------------------------------------------------- +const rtl::OUString OEvoabDriver::getEvoab_CLI_Path() const +{ + rtl::OUString aEvoab_CLI_Path; + sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/'); + + if ( nLen == -1 ) + { + rtl::OUString aDefault_CLI_FullPathCommand; + aDefault_CLI_FullPathCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND())); + sal_Int32 nLength = aDefault_CLI_FullPathCommand.lastIndexOf('/'); + aEvoab_CLI_Path = aDefault_CLI_FullPathCommand.copy(0, nLength+1); + } + else + aEvoab_CLI_Path = m_aEvoab_CLI_FullPathCommand.copy(0, nLen+1); + EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Path()::aEvoab_CLI_Path = %s", aEvoab_CLI_Path ); + + return aEvoab_CLI_Path; +} +// ------------------------------------------------------------------------- +const rtl::OUString OEvoabDriver::getWorkingDirPath() const +{ + ::rtl::OUString aWorkingDirPath; + if(m_bWorkingDirCreated) + osl::File::getSystemPathFromFileURL( m_aWorkingDirURL, aWorkingDirPath ); + return aWorkingDirPath; +} +// ------------------------------------------------------------------------- +const String OEvoabDriver::getEvoFolderListFileURL() const +{ + + ::rtl::OUString aEvoFolderListFileURL; + aEvoFolderListFileURL = getWorkingDirURL() + getEvoFolderListFileName(); + + EVO_TRACE_STRING("OEvoabDriver::getEvoFolderListFileURL(): aEvoFolderListFileURL = %s", aEvoFolderListFileURL ); + return aEvoFolderListFileURL.getStr(); +} + +// ------------------------------------------------------------------------- +String OEvoabDriver::getTempDirURL() const +{ + ::rtl::OUString aTempDirURL; + aTempDirURL = m_aTempDir.GetURL(); + if((aTempDirURL.lastIndexOf( '/')) != (aTempDirURL.getLength( ) - 1)) + aTempDirURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); + + EVO_TRACE_STRING("OEvoabDriver::getTempDirURL(): aTempDirURL = %s", aTempDirURL ); + return aTempDirURL.getStr(); +} +//------------------------------------------------------------------------- +sal_Bool OEvoabDriver::fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir) const +{ + ::ucbhelper::Content aCheckExistence; + sal_Bool bExists = sal_False; + try + { + aCheckExistence = ::ucbhelper::Content(_rURL, Reference< XCommandEnvironment >()); + if(_bIsDir) + bExists = aCheckExistence.isFolder(); + else + bExists = aCheckExistence.isDocument(); + } + catch(const Exception&) { } + return bExists; +} + +// ----------------------------------------------------------------------------- +const sal_Char* OEvoabDriver::getSDBC_SCHEME_EVOLUTION() +{ + static const sal_Char* SDBC_SCHEME_EVOLUTION = EVOAB_EVOLUTION_SCHEMA; + return SDBC_SCHEME_EVOLUTION; +} +const sal_Char* OEvoabDriver::getEVOAB_FOLDERLIST_FILE_NAME() +{ + static const sal_Char* EVOAB_FOLDERLIST_FILE_NAME = "FolderList"; + return EVOAB_FOLDERLIST_FILE_NAME; +} +const sal_Char* OEvoabDriver::getEVOAB_VERSION_FILE_NAME() +{ + static const sal_Char* EVOAB_VERSION_FILE_NAME = "EvoVersion"; + return EVOAB_VERSION_FILE_NAME; +} +const sal_Char* OEvoabDriver::getEVOAB_META_FILE_EXT() +{ + static const sal_Char* EVOAB_META_FILE_EXT = "csv"; + return EVOAB_META_FILE_EXT; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND() +{ + static const sal_Char* EVOAB_CLI_FULLPATHCOMMAND = "file:///home/evoab/extra/share/evolution/*/tools/evolution-addressbook-export"; + return EVOAB_CLI_FULLPATHCOMMAND; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS() +{ + static const sal_Char* EVOAB_CLI_ARG_LIST_FOLDERS = "-l"; + return EVOAB_CLI_ARG_LIST_FOLDERS; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX() +{ + static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX = "--output="; + return EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FORMAT() +{ + static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FORMAT = "--format=csv"; + return EVOAB_CLI_ARG_OUTPUT_FORMAT; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_VERSION() +{ + static const sal_Char* EVOAB_CLI_ARG_VERSION = "--version"; + return EVOAB_CLI_ARG_VERSION; +} +const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_REDIRECT() +{ + static const sal_Char* EVOAB_CLI_ARG_OUTPUT_REDIRECT = ">"; + return EVOAB_CLI_ARG_OUTPUT_REDIRECT; +} +rtl::OUString OEvoabDriver::translateFileErrorMessage( oslFileError nFileErr) +{ + ::rtl::OUString sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" no file operation!.")); + switch (nFileErr) + { + case osl_File_E_None: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation succeeded!")); + break; + case osl_File_E_INVAL: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: the format of the parameters was not valid!")); + break; + case osl_File_E_INTR: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: function call was interrupted!")); + break; + case osl_File_E_IO: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: I/O errors!")); + break; + case osl_File_E_ISDIR: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: is a directory!")); + break; + case osl_File_E_BADF: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad file!")); + break; + case osl_File_E_FAULT: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad address!")); + break; + case osl_File_E_AGAIN: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: operation would block!")); + break; + case osl_File_E_NOLINK: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: link has been severed!")); + break; + default: + sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: other reason!")); + } + return sFileErr; +} +// ----------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL OEvoabDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) +{ + if ( !acceptsURL(url) ) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); + ::dbtools::throwGenericSQLException(sMessage ,*this); + } // if ( !acceptsURL(url) ) + return Sequence< DriverPropertyInfo >(); +} diff --git a/connectivity/source/drivers/evoab/LDriver.hxx b/connectivity/source/drivers/evoab/LDriver.hxx new file mode 100644 index 000000000000..bf45c93d9531 --- /dev/null +++ b/connectivity/source/drivers/evoab/LDriver.hxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LDriver.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LDRIVER_HXX_ +#define _CONNECTIVITY_EVOAB_LDRIVER_HXX_ + +#include +#include "connectivity/CommonTools.hxx" +#include "file/FDriver.hxx" +#include +#include +#include + +#define EVOAB_EVOLUTION_SCHEMA "evolution" +#define EVOAB_LDAP_SCHEMA "ldap" +#define EVOAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.evoab.OEvoabDriver" + +namespace connectivity +{ + namespace evoab + { + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + class OEvoabDriver : public file::OFileDriver + { + private: + enum MaybeVoidBool + { + eUnknown, + eTrue, + eFalse + }; + ::utl::TempFile m_aTempDir; + rtl::OUString m_aFolderListName; + rtl::OUString m_aVersionName; + rtl::OUString m_aFileExt; + rtl::OUString m_aWorkingDirURL; + rtl::OUString m_aEvoab_CLI_EffectiveCommand; + rtl::OUString m_aEvoab_CLI_FullPathCommand; + sal_Bool m_bWorkingDirCreated; + MaybeVoidBool m_eSupportedEvoVersion; + + sal_Bool fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir=sal_False) const; + + public: + OEvoabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + + inline rtl::OUString getEvoFolderListName() const { return m_aFolderListName;} + inline rtl::OUString getFileExt() const { return m_aFileExt;} + inline rtl::OUString getEvoFolderListFileName() const { return m_aFolderListName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;} + inline rtl::OUString getEvoVersionFileName() const { return m_aVersionName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;} + inline rtl::OUString getWorkingDirURL() const { return m_aWorkingDirURL;} + inline rtl::OUString getEvoab_CLI_FullPathCommand() const { return m_aEvoab_CLI_FullPathCommand;} + inline rtl::OUString getEvoab_CLI_EffectiveCommand() const { return m_aEvoab_CLI_EffectiveCommand;} + inline sal_Bool doesEvoab_CLI_HavePath() const { return m_aEvoab_CLI_FullPathCommand.lastIndexOf('/')!=-1;} + const rtl::OUString getEvoab_CLI_Command() const; + const rtl::OUString getEvoab_CLI_Path() const; + const rtl::OUString getWorkingDirPath() const; + const String getEvoFolderListFileURL() const; + String getTempDirURL() const; + + // XInterface + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + // static methods + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static sal_Bool acceptsURL_Stat( const ::rtl::OUString& url ); + static ::rtl::OUString translateProcessErrorMessage( oslProcessError nProcErr); + static ::rtl::OUString translateFileErrorMessage( oslFileError nFileErr); + static const sal_Char* getSDBC_SCHEME_EVOLUTION(); + static const sal_Char* getEVOAB_FOLDERLIST_FILE_NAME(); + static const sal_Char* getEVOAB_VERSION_FILE_NAME(); + static const sal_Char* getEVOAB_META_FILE_EXT(); + static const sal_Char* getEVOAB_CLI_FULLPATHCOMMAND(); + static const sal_Char* getEVOAB_CLI_ARG_LIST_FOLDERS(); + static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX(); + static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FORMAT(); + static const sal_Char* getEVOAB_CLI_ARG_VERSION(); + static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_REDIRECT(); + + }; + } + +} +#endif //_CONNECTIVITY_EVOAB_LDRIVER_HXX_ diff --git a/connectivity/source/drivers/evoab/LFolderList.cxx b/connectivity/source/drivers/evoab/LFolderList.cxx new file mode 100644 index 000000000000..a3c031c05c05 --- /dev/null +++ b/connectivity/source/drivers/evoab/LFolderList.cxx @@ -0,0 +1,566 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LFolderList.cxx,v $ + * $Revision: 1.15 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include +#include +#include "LFolderList.hxx" +#include +#include +#include +#include "LConnection.hxx" +#include "LColumns.hxx" +#include +#include +#include +#include +#include +#include //sprintf +#include +#include +#include "LDriver.hxx" +#include +#include +#include +#include "connectivity/dbconversion.hxx" +#include +#include +#include +#include "connectivity/dbexception.hxx" +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#include "LDebug.hxx" +#endif +#include + +using namespace ::comphelper; +using namespace connectivity; +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace ::cppu; +using namespace utl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +void OEvoabFolderList::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) +{ + BOOL bRead = TRUE; + + QuotedTokenizedString aHeaderLine; + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + + // read first row + QuotedTokenizedString aFirstLine; + bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); + + while(bRead && !aFirstLine.Len()) + { + bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); + } + // use first row as headerline because we need the number of columns + aHeaderLine = aFirstLine; + + // column count + xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + + if(!m_aColumns.isValid()) + m_aColumns = new OSQLColumns(); + else + m_aColumns->get().clear(); + + m_aTypes.clear(); + m_aPrecisions.clear(); + m_aScales.clear(); + // reserve some space + m_aColumns->get().reserve(nFieldCount); + m_aTypes.reserve(nFieldCount); + m_aPrecisions.reserve(nFieldCount); + m_aScales.reserve(nFieldCount); + + sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale); + // read description + sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); + sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); + String aColumnName; + ::rtl::OUString aTypeName; + ::comphelper::UStringMixEqual aCase(bCase); + xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens + xub_StrLen nStartPosFirstLine2 = 0; + for (xub_StrLen i = 0; i < nFieldCount; i++) + { + + // no column name so ... + aColumnName = 'C'; + aColumnName += String::CreateFromInt32(i+1); + + sal_Int32 eType; + UINT16 nPrecision = 0; + UINT16 nScale = 0; + + BOOL bNumeric = FALSE; + ULONG nIndex = 0; + + // first without fielddelimiter + String aField; + aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0'); + if (aField.Len() == 0 || + (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0))) + { + bNumeric = FALSE; + } + else + { + String aField2; + if ( pConnection->getStringDelimiter() != '\0' ) + aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + else + aField2 = aField; + + if (aField2.Len() == 0) + { + bNumeric = FALSE; + } + else + { + bNumeric = TRUE; + xub_StrLen nDot = 0; + for (xub_StrLen j = 0; j < aField2.Len(); j++) + { + sal_Unicode c = aField2.GetChar(j); + // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? + if ((!cDecimalDelimiter || c != cDecimalDelimiter) && + (!cThousandDelimiter || c != cThousandDelimiter) && + !aCharClass.isDigit(aField2,j)) + { + bNumeric = FALSE; + break; + } + if (cDecimalDelimiter && c == cDecimalDelimiter) + { + nPrecision = 15; // we have an decimal value + nScale = 2; + nDot++; + } + } + + if (nDot > 1) // if there is more than one dot it isn't a number + bNumeric = FALSE; + if (bNumeric && cThousandDelimiter) + { + // Ist der Trenner richtig angegeben? + String aValue = aField2.GetToken(0,cDecimalDelimiter); + for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4) + { + sal_Unicode c = aValue.GetChar(j); + // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? + if (c == cThousandDelimiter && j) + continue; + else + { + bNumeric = FALSE; + break; + } + } + } + + // jetzt koennte es noch ein Datumsfeld sein + if (!bNumeric) + { + try + { + nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2); + } + catch(Exception&) + { + } + } + } + } + + sal_Int32 nFlags = 0; + if (bNumeric) + { + if (cDecimalDelimiter) + { + if(nPrecision) + { + eType = DataType::DECIMAL; + aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); + } + else + { + eType = DataType::DOUBLE; + aTypeName = ::rtl::OUString::createFromAscii("DOUBLE"); + } + } + else + eType = DataType::INTEGER; + nFlags = ColumnSearch::BASIC; + } + else + { + + switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex)) + { + case NUMBERFORMAT_DATE: + eType = DataType::DATE; + aTypeName = ::rtl::OUString::createFromAscii("DATE"); + break; + case NUMBERFORMAT_DATETIME: + eType = DataType::TIMESTAMP; + aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP"); + break; + case NUMBERFORMAT_TIME: + eType = DataType::TIME; + aTypeName = ::rtl::OUString::createFromAscii("TIME"); + break; + default: + eType = DataType::VARCHAR; + nPrecision = 0; // nyi: Daten koennen aber laenger sein! + nScale = 0; + aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); + }; + nFlags |= ColumnSearch::CHAR; + } + + // check if the columname already exists + String aAlias(aColumnName); + OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + sal_Int32 nExprCnt = 0; + while(aFind != m_aColumns->get().end()) + { + (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt); + aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + } + + sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(), + ColumnValue::NULLABLE, + nPrecision, + nScale, + eType, + sal_False, + sal_False, + sal_False, + bCase); + Reference< XPropertySet> xCol = pColumn; + m_aColumns->get().push_back(xCol); + m_aTypes.push_back(eType); + m_aPrecisions.push_back(nPrecision); + m_aScales.push_back(nScale); + } + m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); +} +// ------------------------------------------------------------------------- +DBG_NAME( OEvoabFolderList ); +OEvoabFolderList::OEvoabFolderList(OEvoabConnection* _pConnection) + :m_nFilePos(0) + ,m_pFileStream(NULL) + ,m_pConnection(_pConnection) + ,m_bIsNull(sal_False) +{ + DBG_CTOR( OEvoabFolderList, NULL ); + m_aColumns = new OSQLColumns(); + + construct(); +} +// ----------------------------------------------------------------------------- +void OEvoabFolderList::construct() +{ + SvtSysLocale aLocale; + ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale()); + Sequence< ::com::sun::star::uno::Any > aArg(1); + aArg[0] <<= aAppLocale; + + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY); + m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY); + m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier); + + INetURLObject aURL; + aURL.SetURL(m_pConnection->getDriver()->getEvoFolderListFileURL()); + + String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); + + EVO_TRACE_STRING("OJ::construct()::aFileName = %s\n", aFileName ); + m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); + + if(!m_pFileStream) + m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE); + + if(m_pFileStream) + { + m_pFileStream->Seek(STREAM_SEEK_TO_END); + sal_Int32 nSize = m_pFileStream->Tell(); + m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); + + // Buffersize abhaengig von der Filegroesse + m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 : + nSize > 100000 ? 16384 : + nSize > 10000 ? 4096 : 1024); + OSL_TRACE("OEvoabFolderList::construct()::m_pFileStream->Tell() = %d\n", nSize ); + + fillColumns(aAppLocale); + } +} + + +//------------------------------------------------------------------ +sal_Bool OEvoabFolderList::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols) +{ + (_rRow->get())[0] = m_nFilePos; // the "bookmark" + + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + // Felder: + xub_StrLen nStartPos = 0; + String aStr; + OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); + for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i) + { + m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + //OSL_TRACE("OEvoabFolderList::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) ); + + if (aStr.Len() == 0) + (_rRow->get())[i+1].setNull(); + else + { + // length depending on the data type + sal_Int32 nType = m_aTypes[i]; + switch(nType) + { + case DataType::TIMESTAMP: + case DataType::DATE: + case DataType::TIME: + { + double nRes = 0.0; + try + { + nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr); + Reference xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY); + com::sun::star::util::Date aDate; + xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate; + + switch(nType) + { + case DataType::DATE: + (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); + break; + case DataType::TIMESTAMP: + (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); + break; + default: + (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); + } + } + catch(Exception&) + { + (_rRow->get())[i+1].setNull(); + } + } break; + case DataType::DOUBLE: + case DataType::INTEGER: + case DataType::DECIMAL: // #99178# OJ + case DataType::NUMERIC: + { + sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); + sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); + String aStrConverted; + + OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER || + !cDecimalDelimiter && nType == DataType::INTEGER, + "FalscherTyp"); + + // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln: + for (xub_StrLen j = 0; j < aStr.Len(); ++j) + { + if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter) + aStrConverted += '.'; + else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it + break; // #99189# OJ + else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter) + { + // weglassen + } + else + aStrConverted += aStr.GetChar(j) ; + } + double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL); + + // #99178# OJ + if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType ) + (_rRow->get())[i+1] = String::CreateFromDouble(nVal); + else + (_rRow->get())[i+1] = nVal; + } break; + + default: + { + // Wert als String in Variable der Row uebernehmen + (_rRow->get())[i+1] = aStr; + } + break; + } + } + } + return sal_True; +} + + +//------------------------------------------------------------------ +sal_Bool OEvoabFolderList::seekRow(IResultSetHelper::Movement eCursorPosition) +{ + //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + if ( !m_pFileStream ) + return sal_False; + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + // ---------------------------------------------------------- + // Positionierung vorbereiten: + //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + switch(eCursorPosition) + { + case IResultSetHelper::FIRST: + m_nFilePos = 0; + // run through + + case IResultSetHelper::NEXT: + m_pFileStream->Seek(m_nFilePos); + + if (m_pFileStream->IsEof()) + { + OSL_TRACE( "OEvoabFolderList::seekRow: EOF /before/ reading the line." ); + return sal_False; + } + + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + { + OSL_TRACE( "OEvoabFolderList::seekRow: EOF /after/ reading the line." ); + if ( !m_aCurrentLine.Len() ) + { + OSL_TRACE( "OEvoabFolderList::seekRow: empty line read." ); + return sal_False; + } + } + m_nFilePos = m_pFileStream->Tell(); + break; + + default: + OSL_ENSURE( sal_False, "OEvoabFolderList::seekRow: unsupported positioning!" ); + break; + } + + //OSL_TRACE("OEvoabFolderList::seekRow()::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + return sal_True; +} +// ----------------------------------------------------------------------------- +SvStream* OEvoabFolderList::createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode) +{ + utl::UcbLockBytesHandler* p_null_dummy=NULL; + SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, p_null_dummy); + if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode())) + { + delete pReturn; + pReturn = NULL; + } + return pReturn; +} +// ----------------------------------------------------------------------------- +const ORowSetValue& OEvoabFolderList::getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException) +{ + checkIndex( _nColumnIndex ); + + m_bIsNull = (m_aRow->get())[_nColumnIndex].isNull(); + return (m_aRow->get())[_nColumnIndex]; +} +// ----------------------------------------------------------------------------- +void OEvoabFolderList::checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException) +{ + if ( _nColumnIndex <= 0 || _nColumnIndex >= (sal_Int32)m_aRow->get().size() ) { +// ::dbtools::throwInvalidIndexException(); + ; + } +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OEvoabFolderList::getString( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(_nColumnIndex); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OEvoabFolderList::getInt( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException) +{ + return getValue( _nColumnIndex ); +} +// ----------------------------------------------------------------------------- +void OEvoabFolderList::initializeRow(sal_Int32 _nColumnCount) +{ + if(!m_aRow.isValid()) + { + m_aRow = new OValueVector(_nColumnCount); + (m_aRow->get())[0].setBound(sal_True); + ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False)); + } + //OSL_TRACE("OEvoabFolderList::initializeRow()::_nColumnCount = %d\n", _nColumnCount); + +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OEvoabFolderList::first( ) throw(SQLException, RuntimeException) +{ + sal_Bool bSuccess = seekRow(IResultSetHelper::FIRST); + + EVO_TRACE_STRING("OEvoabFolderList::first(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) ); + return bSuccess; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OEvoabFolderList::next( ) throw(SQLException, RuntimeException) +{ + sal_Bool bSuccess = seekRow(IResultSetHelper::NEXT); + + EVO_TRACE_STRING("OEvoabFolderList::next(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) ); + return bSuccess; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OEvoabFolderList::getRow( ) throw(SQLException, RuntimeException) +{ + sal_Bool bRet = fetchRow(m_aRow,getTableColumns().getBody()); + EVO_TRACE_STRING("OEvoabFolderList::getRow()::fetchRow() = %s\n", ::rtl::OUString::valueOf(bRet) ); + + return bRet; +} diff --git a/connectivity/source/drivers/evoab/LFolderList.hxx b/connectivity/source/drivers/evoab/LFolderList.hxx new file mode 100644 index 000000000000..baa2a3b05e86 --- /dev/null +++ b/connectivity/source/drivers/evoab/LFolderList.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LFolderList.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ +#define _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ + +#include "connectivity/sdbcx/VColumn.hxx" +#include "connectivity/CommonTools.hxx" +#include +#include "LTable.hxx" +#include "TResultSetHelper.hxx" + + +namespace connectivity +{ + namespace evoab + { + //================================================================== + // Ableitung von String mit ueberladenen GetToken/GetTokenCount-Methoden + // Speziell fuer FLAT FILE-Format: Strings koennen gequotet sein + //================================================================== + + class OEvoabConnection; + + class OEvoabFolderList + { + // maps a row postion to a file position + ::std::vector m_aTypes; // holds all type for columns just to avoid to ask the propertyset + ::std::vector m_aPrecisions; // same as aboth + ::std::vector m_aScales; + QuotedTokenizedString m_aCurrentLine; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter; + sal_Int32 m_nFilePos; // aktuelle IResultSetHelper::Movement + SvStream* m_pFileStream; + OEvoabConnection* m_pConnection; + ::vos::ORef m_aColumns; + OValueRow m_aRow; + sal_Bool m_bIsNull; + + private: + void fillColumns(const ::com::sun::star::lang::Locale& _aLocale); + BOOL CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo); + + sal_Bool fetchRow(OValueRow _rRow,const OSQLColumns& _rCols); + sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition); + + public: + + OEvoabFolderList( OEvoabConnection* _pConnection); + + OEvoabConnection* getConnection() const { return m_pConnection;} + ::vos::ORef getTableColumns() const {return m_aColumns;} + void construct(); // can throw any exception + static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode); + void initializeRow(sal_Int32 _nColumnCount); + void checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException); + const ORowSetValue& getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException); + ::rtl::OUString SAL_CALL getString( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 SAL_CALL getInt( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ + diff --git a/connectivity/source/drivers/evoab/LNoException.cxx b/connectivity/source/drivers/evoab/LNoException.cxx new file mode 100644 index 000000000000..183ab75559f4 --- /dev/null +++ b/connectivity/source/drivers/evoab/LNoException.cxx @@ -0,0 +1,327 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LNoException.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LTable.hxx" +#include "LConnection.hxx" + +using namespace connectivity; +using namespace connectivity::evoab; + +//------------------------------------------------------------------ +xub_StrLen OEvoabString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const +{ + if ( !Len() ) + return 0; + + xub_StrLen nTokCount = 1; + BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token? + BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String? + + // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen + for( xub_StrLen i = 0; i < Len(); i++ ) + { + if (bStart) + { + bStart = FALSE; + // Erstes Zeichen ein String-Delimiter? + if ((*this).GetChar(i) == cStrDel) + { + bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings! + continue; // dieses Zeichen ueberlesen! + } + } + + if (bInString) { + // Wenn jetzt das String-Delimiter-Zeichen auftritt ... + if ( (*this).GetChar(i) == cStrDel ) + { + if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) + { + // Verdoppeltes String-Delimiter-Zeichen: + i++; // kein String-Ende, naechstes Zeichen ueberlesen. + } + else + { + // String-Ende + bInString = FALSE; + } + } + } else { + // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount + if ( (*this).GetChar(i) == cTok ) + { + nTokCount++; + bStart = TRUE; + } + } + } + //OSL_TRACE("OEvoabString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) ); + + return nTokCount; +} + +//------------------------------------------------------------------ +void OEvoabString::GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel ) const +{ + _rStr.Erase(); + xub_StrLen nLen = Len(); + if ( nLen ) + { + BOOL bInString = (nStartPos < nLen) && ((*this).GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String? + + // Erstes Zeichen ein String-Delimiter? + if (bInString ) + ++nStartPos; // dieses Zeichen ueberlesen! + // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen + for( xub_StrLen i = nStartPos; i < nLen; ++i ) + { + if (bInString) + { + // Wenn jetzt das String-Delimiter-Zeichen auftritt ... + if ( (*this).GetChar(i) == cStrDel ) + { + if ((i+1 < nLen) && ((*this).GetChar(i+1) == cStrDel)) + { + // Verdoppeltes String-Delimiter-Zeichen: + ++i; // kein String-Ende, naechstes Zeichen ueberlesen. + + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + else + { + // String-Ende + bInString = FALSE; + } + } + else + { + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + + } + else + { + // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok + if ( (*this).GetChar(i) == cTok ) + { + // Vorzeitiger Abbruch der Schleife moeglich, denn + // wir haben, was wir wollten. + nStartPos = i+1; + break; + } + else + { + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + } + } + } +} +// ----------------------------------------------------------------------------- +void OEvoabTable::refreshIndexes() +{ +} +// ----------------------------------------------------------------------------- +sal_Bool OEvoabTable::checkHeaderLine() +{ + if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine()) + { + BOOL bRead2; + do + { + bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding()); + } + while(bRead2 && !m_aCurrentLine.Len()); + + m_nFilePos = m_pFileStream->Tell(); + if (m_pFileStream->IsEof()) + return sal_False; + } + return sal_True; +} +//------------------------------------------------------------------ +sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + if ( !m_pFileStream ) + return sal_False; + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + // ---------------------------------------------------------- + // Positionierung vorbereiten: + //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + m_nFilePos = nCurPos; + + switch(eCursorPosition) + { + case IResultSetHelper::FIRST: + m_nFilePos = 0; + m_nRowPos = 1; + // run through + case IResultSetHelper::NEXT: + if(eCursorPosition != IResultSetHelper::FIRST) + ++m_nRowPos; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + + m_aRowToFilePos.insert(::std::map::value_type(m_nRowPos,m_nFilePos)); + + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + nCurPos = m_pFileStream->Tell(); + break; + case IResultSetHelper::PRIOR: + --m_nRowPos; + if(m_nRowPos > 0) + { + m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + m_nRowPos = 0; + + break; + + break; + case IResultSetHelper::LAST: + if(m_nMaxRowCount) + { + m_nFilePos = m_aRowToFilePos.rbegin()->second; + m_nRowPos = m_aRowToFilePos.rbegin()->first; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + { + while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row + // now I know all + seekRow(IResultSetHelper::PRIOR,1,nCurPos); + } + break; + case IResultSetHelper::RELATIVE: + if(nOffset > 0) + { + for(sal_Int32 i = 0;i::const_iterator aIter = m_aRowToFilePos.find(nOffset); + if(aIter != m_aRowToFilePos.end()) + { + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table + { + m_nRowPos = m_nMaxRowCount; + return sal_False; + } + else + { + aIter = m_aRowToFilePos.upper_bound(nOffset); + if(aIter == m_aRowToFilePos.end()) + { + m_nRowPos = m_aRowToFilePos.rbegin()->first; + nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; + while(m_nRowPos != nOffset) + seekRow(IResultSetHelper::NEXT,1,nCurPos); + } + else + { + --aIter; + m_nRowPos = aIter->first; + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + } + } + + break; + case IResultSetHelper::BOOKMARK: + m_pFileStream->Seek(nOffset); + if (m_pFileStream->IsEof()) + return sal_False; + + m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + break; + } + + //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + return sal_True; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.cxx b/connectivity/source/drivers/evoab/LPreparedStatement.cxx new file mode 100644 index 000000000000..fa4269fdce4d --- /dev/null +++ b/connectivity/source/drivers/evoab/LPreparedStatement.cxx @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LPreparedStatement.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LPreparedStatement.hxx" +#include "LResultSet.hxx" + +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +// ------------------------------------------------------------------------- +OResultSet* OEvoabPreparedStatement::createResultSet() +{ + return new OEvoabResultSet(this,m_aSQLIterator); +} +// ------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbc.driver.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); + diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.hxx b/connectivity/source/drivers/evoab/LPreparedStatement.hxx new file mode 100644 index 000000000000..e4260ef3a994 --- /dev/null +++ b/connectivity/source/drivers/evoab/LPreparedStatement.hxx @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LPreparedStatement.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ + +#include "file/FPreparedStatement.hxx" + +namespace connectivity +{ + namespace evoab + { + class OConnection; + class OEvoabPreparedStatement : public file::OPreparedStatement + { + protected: + virtual file::OResultSet* createResultSet(); + public: + OEvoabPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){}; + DECLARE_SERVICE_INFO(); + }; + } +} + +#endif //_CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ + diff --git a/connectivity/source/drivers/evoab/LResultSet.cxx b/connectivity/source/drivers/evoab/LResultSet.cxx new file mode 100644 index 000000000000..fd4959465710 --- /dev/null +++ b/connectivity/source/drivers/evoab/LResultSet.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LResultSet.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include +#include +#include "LResultSet.hxx" +#include +#include +#include + +using namespace ::comphelper; + +using namespace connectivity::evoab; +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; +//------------------------------------------------------------------------------ +OEvoabResultSet::OEvoabResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) + : file::OResultSet(pStmt,_aSQLIterator) + ,m_bBookmarkable(sal_True) +{ + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType()); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.evoab.ResultSet"); +} +// ------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL OEvoabResultSet::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 OEvoabResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); + for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) + ; + + return pSupported != pEnd; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if(rType == ::getCppuType((const Reference*)0) || rType == ::getCppuType((const Reference*)0) + || rType == ::getCppuType((const Reference*)0)) + return Any(); + + Any aRet = OResultSet::queryInterface(rType); + return aRet.hasValue() ? aRet : OEvoabResultSet_BASE::queryInterface(rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) +{ + Sequence< Type > aTypes = OResultSet::getTypes(); + ::std::vector aOwnTypes; + aOwnTypes.reserve(aTypes.getLength()); + const Type* pBegin = aTypes.getConstArray(); + const Type* pEnd = pBegin + aTypes.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if(!(*pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0))) + { + aOwnTypes.push_back(*pBegin); + } + } + Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; + Sequence< Type > aRet(pTypes, aOwnTypes.size()); + return ::comphelper::concatSequences(aRet,OEvoabResultSet_BASE::getTypes()); +} + +// ------------------------------------------------------------------------- +// XRowLocate +Any SAL_CALL OEvoabResultSet::getBookmark( ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OEvoabResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; + + return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OEvoabResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; + + Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False); + + return relative(rows); +} + +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OEvoabResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException) +{ + return (lhs == rhs) ? 0 : 2; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OEvoabResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OEvoabResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) +{ + return comphelper::getINT32(bookmark); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() +{ + return *OEvoabResultSet_BASE3::getArrayHelper(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OEvoabResultSet::acquire() throw() +{ + OEvoabResultSet_BASE2::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OEvoabResultSet::release() throw() +{ + OEvoabResultSet_BASE2::release(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/evoab/LResultSet.hxx b/connectivity/source/drivers/evoab/LResultSet.hxx new file mode 100644 index 000000000000..f93ba9364e5a --- /dev/null +++ b/connectivity/source/drivers/evoab/LResultSet.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LResultSet.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LRESULTSET_HXX_ +#define _CONNECTIVITY_EVOAB_LRESULTSET_HXX_ + +#include "file/FResultSet.hxx" +#include +#include + +namespace connectivity +{ + namespace evoab + { + class OEvoabResultSet; + // these typedef's are only necessary for the compiler + typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XRowLocate> OEvoabResultSet_BASE; + typedef file::OResultSet OEvoabResultSet_BASE2; + typedef ::comphelper::OPropertyArrayUsageHelper OEvoabResultSet_BASE3; + + + class OEvoabResultSet : public OEvoabResultSet_BASE2, + public OEvoabResultSet_BASE, + public OEvoabResultSet_BASE3 + { + sal_Bool m_bBookmarkable; + protected: + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + public: + DECLARE_SERVICE_INFO(); + + OEvoabResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif //_CONNECTIVITY_EVOAB_LRESULTSET_HXX_ + diff --git a/connectivity/source/drivers/evoab/LServices.cxx b/connectivity/source/drivers/evoab/LServices.cxx new file mode 100644 index 000000000000..bab5ae8cfce9 --- /dev/null +++ b/connectivity/source/drivers/evoab/LServices.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LServices.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LDriver.hxx" +#include +#include + +using namespace connectivity::evoab; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames, + rtl_ModuleCount* _pT + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !"); + + for (sal_Int32 i=0; icreateKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment ** /*ppEnv*/ + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void* /*pServiceManager*/, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + OEvoabDriver::getImplementationName_Static(), + OEvoabDriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* /*pRegistryKey*/) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + OEvoabDriver::getImplementationName_Static(), + OEvoabDriver::getSupportedServiceNames_Static(), + OEvoabDriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + diff --git a/connectivity/source/drivers/evoab/LStatement.cxx b/connectivity/source/drivers/evoab/LStatement.cxx new file mode 100644 index 000000000000..9ef945b1ccd4 --- /dev/null +++ b/connectivity/source/drivers/evoab/LStatement.cxx @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LStatement.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LStatement.hxx" +#include "LResultSet.hxx" + +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace com::sun::star::uno; +// ------------------------------------------------------------------------- +OResultSet* OEvoabStatement::createResultSet() +{ + return new OEvoabResultSet(this,m_aSQLIterator); +} +// ------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OEvoabStatement,"com.sun.star.sdbc.driver.evoab.Statement","com.sun.star.sdbc.Statement"); + diff --git a/connectivity/source/drivers/evoab/LStatement.hxx b/connectivity/source/drivers/evoab/LStatement.hxx new file mode 100644 index 000000000000..9e8af7f7b273 --- /dev/null +++ b/connectivity/source/drivers/evoab/LStatement.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LStatement.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ +#define _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ + +#include "file/FStatement.hxx" + +namespace connectivity +{ + namespace evoab + { + class OConnection; + class OEvoabStatement : public file::OStatement + { + protected: + virtual file::OResultSet* createResultSet(); + public: + OEvoabStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} + DECLARE_SERVICE_INFO(); + }; + } +} + +#endif //_CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ diff --git a/connectivity/source/drivers/evoab/LTable.cxx b/connectivity/source/drivers/evoab/LTable.cxx new file mode 100644 index 000000000000..cbb4bc53e9f4 --- /dev/null +++ b/connectivity/source/drivers/evoab/LTable.cxx @@ -0,0 +1,873 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LTable.cxx,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include +#include "LTable.hxx" +#include +#include +#include +#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ +//#include +#endif +#include +#include "LConnection.hxx" +#include "LColumns.hxx" +#include +#include +#include +#include +#include +#include //sprintf +#include +#include +#include "LDriver.hxx" +#include +#include +#include +#include "connectivity/dbconversion.hxx" +#include +#include +#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX +#include "LDebug.hxx" +#endif +#include + +using namespace ::comphelper; +using namespace connectivity; +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace ::cppu; +using namespace utl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +void OEvoabTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) +{ + BOOL bRead = TRUE; + + QuotedTokenizedString aHeaderLine; + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + if (pConnection->isHeaderLine()) + { + while(bRead && !aHeaderLine.Len()) + { + bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,pConnection->getTextEncoding()); + } + } + + // read first row + QuotedTokenizedString aFirstLine; + bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); + + if (!pConnection->isHeaderLine() || !aHeaderLine.Len()) + { + while(bRead && !aFirstLine.Len()) + { + bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); + } + // use first row as headerline because we need the number of columns + aHeaderLine = aFirstLine; + } + // column count + xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + + if(!m_aColumns.isValid()) + m_aColumns = new OSQLColumns(); + else + m_aColumns->get().clear(); + + m_aTypes.clear(); + m_aPrecisions.clear(); + m_aScales.clear(); + // reserve some space + m_aColumnRawNames.reserve(nFieldCount); + m_aColumns->get().reserve(nFieldCount); + m_aTypes.reserve(nFieldCount); + m_aPrecisions.reserve(nFieldCount); + m_aScales.reserve(nFieldCount); + + sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale); + // read description + sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); + sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); + String aColumnName; + ::rtl::OUString aTypeName; + ::comphelper::UStringMixEqual aCase(bCase); + xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens + xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens + xub_StrLen nStartPosFirstLine2 = 0; + for (xub_StrLen i = 0; i < nFieldCount; i++) + { + if (pConnection->isHeaderLine()) + { + aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + } + else + { + // no column name so ... + aColumnName = 'C'; + aColumnName += String::CreateFromInt32(i+1); + } + //OSL_TRACE("OEvoabTable::aColumnName = %s\n", ((OUtoCStr(::rtl::OUString(aColumnName))) ? (OUtoCStr(::rtl::OUString(aColumnName))):("NULL")) ); + + sal_Int32 eType; + UINT16 nPrecision = 0; + UINT16 nScale = 0; + + BOOL bNumeric = FALSE; + ULONG nIndex = 0; + + // first without fielddelimiter + String aField; + aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0'); + //OSL_TRACE("OEvoabTable::aField = %s\n", ((OUtoCStr(::rtl::OUString(aField))) ? (OUtoCStr(::rtl::OUString(aField))):("NULL")) ); + + if (aField.Len() == 0 || + (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0))) + { + bNumeric = FALSE; + } + else + { + String aField2; + if ( pConnection->getStringDelimiter() != '\0' ) + aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + else + aField2 = aField; + + //OSL_TRACE("OEvoabTable::aField2 = %s\n", ((OUtoCStr(::rtl::OUString(aField2))) ? (OUtoCStr(::rtl::OUString(aField2))):("NULL")) ); + + if (aField2.Len() == 0) + { + bNumeric = FALSE; + } + else + { + bNumeric = TRUE; + xub_StrLen nDot = 0; + for (xub_StrLen j = 0; j < aField2.Len(); j++) + { + sal_Unicode c = aField2.GetChar(j); + // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? + if ((!cDecimalDelimiter || c != cDecimalDelimiter) && + (!cThousandDelimiter || c != cThousandDelimiter) && + !aCharClass.isDigit(aField2,j)) + { + bNumeric = FALSE; + break; + } + if (cDecimalDelimiter && c == cDecimalDelimiter) + { + nPrecision = 15; // we have an decimal value + nScale = 2; + nDot++; + } + } + + if (nDot > 1) // if there is more than one dot it isn't a number + bNumeric = FALSE; + if (bNumeric && cThousandDelimiter) + { + // Ist der Trenner richtig angegeben? + String aValue = aField2.GetToken(0,cDecimalDelimiter); + for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4) + { + sal_Unicode c = aValue.GetChar(j); + // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? + if (c == cThousandDelimiter && j) + continue; + else + { + bNumeric = FALSE; + break; + } + } + } + + // jetzt koennte es noch ein Datumsfeld sein + if (!bNumeric) + { + try + { + nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2); + } + catch(Exception&) + { + } + } + } + } + + sal_Int32 nFlags = 0; + if (bNumeric) + { + if (cDecimalDelimiter) + { + if(nPrecision) + { + eType = DataType::DECIMAL; + aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); + } + else + { + eType = DataType::DOUBLE; + aTypeName = ::rtl::OUString::createFromAscii("DOUBLE"); + } + } + else + eType = DataType::INTEGER; + nFlags = ColumnSearch::BASIC; + } + else + { + + switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex)) + { + case NUMBERFORMAT_DATE: + eType = DataType::DATE; + aTypeName = ::rtl::OUString::createFromAscii("DATE"); + break; + case NUMBERFORMAT_DATETIME: + eType = DataType::TIMESTAMP; + aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP"); + break; + case NUMBERFORMAT_TIME: + eType = DataType::TIME; + aTypeName = ::rtl::OUString::createFromAscii("TIME"); + break; + default: + eType = DataType::VARCHAR; + nPrecision = 0; // nyi: Daten koennen aber laenger sein! + nScale = 0; + aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); + }; + nFlags |= ColumnSearch::CHAR; + } + + // check if the columname already exists + String aAlias(aColumnName); + OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + sal_Int32 nExprCnt = 0; + while(aFind != m_aColumns->get().end()) + { + (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt); + aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + } + + m_aColumnRawNames.push_back(::rtl::OUString(aAlias)); + + //~ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(), + //~ ColumnValue::NULLABLE, + //~ nPrecision, + //~ nScale, + //~ eType, + //~ sal_False, + //~ sal_False, + //~ sal_False, + //~ bCase); + //~ Reference< XPropertySet> xCol = pColumn; + //~ m_aColumns->push_back(xCol); + m_aTypes.push_back(eType); + m_aPrecisions.push_back(nPrecision); + m_aScales.push_back(nScale); + } + setColumnAliases(); + m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); +} +// ------------------------------------------------------------------------- +OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection) : OEvoabTable_BASE(_pTables,_pConnection) +{ + +} +// ------------------------------------------------------------------------- +OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : OEvoabTable_BASE(_pTables,_pConnection,_Name, + _Type, + _Description, + _SchemaName, + _CatalogName) + ,m_nRowPos(0) + ,m_nMaxRowCount(0) +{ + //~ OSL_TRACE("OEvoabTable::(in constructor)_Name = %s\n", ((OUtoCStr(_Name)) ? (OUtoCStr(_Name)):("NULL")) ); + //~ OSL_TRACE("OEvoabTable::(in constructor)_Type = %s\n", ((OUtoCStr(_Type)) ? (OUtoCStr(_Type)):("NULL")) ); + //~ OSL_TRACE("OEvoabTable::(in constructor)_Description = %s\n", ((OUtoCStr(_Description)) ? (OUtoCStr(_Description)):("NULL")) ); + //~ OSL_TRACE("OEvoabTable::(in constructor)_SchemaName = %s\n", ((OUtoCStr(_SchemaName)) ? (OUtoCStr(_SchemaName)):("NULL")) ); + //~ OSL_TRACE("OEvoabTable::(in constructor)_CatalogName = %s\n", ((OUtoCStr(_CatalogName)) ? (OUtoCStr(_CatalogName)):("NULL")) ); +} +// ----------------------------------------------------------------------------- +void OEvoabTable::construct() +{ + SvtSysLocale aLocale; + ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale()); + Sequence< ::com::sun::star::uno::Any > aArg(1); + aArg[0] <<= aAppLocale; + + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY); + m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY); + m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier); + + INetURLObject aURL; + aURL.SetURL(getEntry()); + + if(aURL.getExtension() != rtl::OUString(m_pConnection->getExtension())) + aURL.setExtension(m_pConnection->getExtension()); + + String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); + + m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); + + if(!m_pFileStream) + m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE); + + if(m_pFileStream) + { + OSL_TRACE("OEvoabTable::construct()::m_pFileStream created\n" ); + m_pFileStream->Seek(STREAM_SEEK_TO_END); + sal_Int32 nSize = m_pFileStream->Tell(); + m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); + + // Buffersize abhaengig von der Filegroesse + m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 : + nSize > 100000 ? 16384 : + nSize > 10000 ? 4096 : 1024); + OSL_TRACE("OEvoabTable::construct()::m_pFileStream->Tell() = %d\n", nSize ); + + fillColumns(aAppLocale); + + refreshColumns(); + } +} +// ------------------------------------------------------------------------- +String OEvoabTable::getEntry() +{ + ::rtl::OUString sURL; + try + { + Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet(); + Reference< XRow> xRow(xDir,UNO_QUERY); + ::rtl::OUString sName; + ::rtl::OUString sExt; + + INetURLObject aURL; + xDir->beforeFirst(); + static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/")); + while(xDir->next()) + { + sName = xRow->getString(1); + aURL.SetSmartProtocol(INET_PROT_FILE); + String sUrl = m_pConnection->getURL() + s_sSeparator + sName; + aURL.SetSmartURL( sUrl ); + + // cut the extension + sExt = aURL.getExtension(); + + // name and extension have to coincide + if ( m_pConnection->matchesExtension( sExt ) ) + { + sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); + if ( sName == m_Name ) + { + Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); + sURL = xContentAccess->queryContentIdentifierString(); + break; + } + } + } + xDir->beforeFirst(); // move back to before first record + } + catch(Exception&) + { + OSL_ASSERT(0); + } + return sURL.getStr(); +} +// ------------------------------------------------------------------------- +void OEvoabTable::refreshColumns() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + TStringVector aVector; + aVector.reserve(m_aColumns->get().size()); + + for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter) + aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName()); + + if(m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new OEvoabColumns(this,m_aMutex,aVector); + + OSL_TRACE("OEvoabTable::refreshColumns()::end\n" ); +} + +// ------------------------------------------------------------------------- +void SAL_CALL OEvoabTable::disposing(void) +{ + OFileTable::disposing(); + ::osl::MutexGuard aGuard(m_aMutex); + m_aColumns = NULL; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OEvoabTable::getTypes( ) throw(RuntimeException) +{ + Sequence< Type > aTypes = OTable_TYPEDEF::getTypes(); + ::std::vector aOwnTypes; + aOwnTypes.reserve(aTypes.getLength()); + const Type* pBegin = aTypes.getConstArray(); + const Type* pEnd = pBegin + aTypes.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if(!(*pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0) || + *pBegin == ::getCppuType((const Reference*)0))) + { + aOwnTypes.push_back(*pBegin); + } + } + Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; + return Sequence< Type >(pTypes, aOwnTypes.size()); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL OEvoabTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if( rType == ::getCppuType((const Reference*)0) || + rType == ::getCppuType((const Reference*)0) || + rType == ::getCppuType((const Reference*)0) || + rType == ::getCppuType((const Reference*)0) || + rType == ::getCppuType((const Reference*)0)) + return Any(); + + Any aRet = OTable_TYPEDEF::queryInterface(rType); + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OEvoabTable::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 OEvoabTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OEvoabTable_BASE::getSomething(rId); +} +//------------------------------------------------------------------ +sal_Bool OEvoabTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData) +{ + *(_rRow->get())[0] = m_nFilePos; + + if (!bRetrieveData) + return TRUE; + + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + // Felder: + xub_StrLen nStartPos = 0; + String aStr; + OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); + for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i) + { + m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + //OSL_TRACE("OEvoabTable::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) ); + + if (aStr.Len() == 0) + (_rRow->get())[i+1]->setNull(); + else + { + // Laengen je nach Datentyp: + sal_Int32 nLen, + nType = 0; + if(bIsTable) + { + nLen = m_aPrecisions[i]; + nType = m_aTypes[i]; + } + else + { + Reference< XPropertySet> xColumn = *aIter; + xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen; + xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; + } + switch(nType) + { + case DataType::TIMESTAMP: + case DataType::DATE: + case DataType::TIME: + { + double nRes = 0.0; + try + { + nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr); + Reference xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY); + com::sun::star::util::Date aDate; + xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate; + + switch(nType) + { + case DataType::DATE: + *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); + break; + case DataType::TIMESTAMP: + *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); + break; + default: + *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); + } + } + catch(Exception&) + { + (_rRow->get())[i+1]->setNull(); + } + } break; + case DataType::DOUBLE: + case DataType::INTEGER: + case DataType::DECIMAL: // #99178# OJ + case DataType::NUMERIC: + { + sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); + sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); + String aStrConverted; + + OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER || + !cDecimalDelimiter && nType == DataType::INTEGER, + "FalscherTyp"); + + // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln: + for (xub_StrLen j = 0; j < aStr.Len(); ++j) + { + if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter) + aStrConverted += '.'; + else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it + break; // #99189# OJ + else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter) + { + // weglassen + } + else + aStrConverted += aStr.GetChar(j) ; + } + double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL); + + // #99178# OJ + if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType ) + *(_rRow->get())[i+1] = ORowSetValue(String::CreateFromDouble(nVal)); + else + *(_rRow->get())[i+1] = nVal; + } break; + + default: + { + // Wert als String in Variable der Row uebernehmen + *(_rRow->get())[i+1] = ORowSetValue(aStr); + } + break; + } + } + } + return sal_True; +} +// ----------------------------------------------------------------------------- +sal_Bool OEvoabTable::setColumnAliases() +{ + + size_t nSize = m_aColumnRawNames.size(); + if(nSize == 0 || m_aPrecisions.size() != nSize || m_aScales.size() != nSize || m_aTypes.size() != nSize) + return sal_False; + m_aColumns->get().clear(); + m_aColumns->get().reserve(nSize); + ::rtl::OUString aColumnReadName; + ::rtl::OUString aColumnHeadlineName; + ::rtl::OUString aColumnDisplayName; + ::rtl::OUString aColumnFinalName; + String sColumnFinalName; + + const TStringVector& colAliasNames = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAlias(); + const ::std::map< ::rtl::OUString, ::rtl::OUString > & colMap = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAliasMap(); + ::osl::MutexGuard aGuard( m_aMutex ); + + for(size_t i = 0;i < nSize; ++i) + { + aColumnReadName = m_aColumnRawNames[i]; + //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnReadName = %s\n", ((OUtoCStr(aColumnReadName)) ? (OUtoCStr(aColumnReadName)):("NULL")) ); + sal_Bool bFound = sal_False; + for ( size_t j = 0; j < colAliasNames.size(); ++j ) + { + aColumnDisplayName = colAliasNames[j]; + + ::std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator aPos = colMap.find( aColumnDisplayName ); + if ( colMap.end() != aPos ) + { + aColumnHeadlineName = aPos->second; + EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", aColumnDisplayName ); + EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnHeadlineName= %s\n", aColumnHeadlineName ); + if(aColumnReadName == aColumnHeadlineName) + { + //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnHeadlineName = %s\n", ((OUtoCStr(aColumnHeadlineName)) ? (OUtoCStr(aColumnHeadlineName)):("NULL")) ); + //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", ((OUtoCStr(aColumnDisplayName)) ? (OUtoCStr(aColumnDisplayName)):("NULL")) ); + aColumnFinalName = aColumnDisplayName; + bFound = sal_True; + //OSL_TRACE("OEvoabTable::getColumnRows()::j = %d\n", j ); + + break; + } + } + else + OSL_ENSURE( sal_False, "OEvoabTable::setColumnAliases: did not find one of the aliases!" ); + } + if(!bFound) + aColumnFinalName = aColumnReadName; + sColumnFinalName = aColumnFinalName; + + sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + ::rtl::OUString aTypeName; + aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); + sdbcx::OColumn* pColumn = new sdbcx::OColumn(sColumnFinalName,aTypeName,::rtl::OUString(), + ColumnValue::NULLABLE, + m_aPrecisions[i], + m_aScales[i], + m_aTypes[i], + sal_False, + sal_False, + sal_False, + bCase); + Reference< XPropertySet> xCol = pColumn; + m_aColumns->get().push_back(xCol); + } + return sal_True; +} +// ----------------------------------------------------------------------------- +void OEvoabTable::refreshIndexes() +{ +} +// ----------------------------------------------------------------------------- +sal_Bool OEvoabTable::checkHeaderLine() +{ + if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine()) + { + BOOL bRead2; + do + { + bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding()); + } + while(bRead2 && !m_aCurrentLine.Len()); + + m_nFilePos = m_pFileStream->Tell(); + if (m_pFileStream->IsEof()) + return sal_False; + } + return sal_True; +} +//------------------------------------------------------------------ +sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + if ( !m_pFileStream ) + return sal_False; + OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; + // ---------------------------------------------------------- + // Positionierung vorbereiten: + //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + m_nFilePos = nCurPos; + + switch(eCursorPosition) + { + case IResultSetHelper::FIRST: + m_nFilePos = 0; + m_nRowPos = 1; + // run through + case IResultSetHelper::NEXT: + if(eCursorPosition != IResultSetHelper::FIRST) + ++m_nRowPos; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + + m_aRowToFilePos.insert(::std::map::value_type(m_nRowPos,m_nFilePos)); + + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + nCurPos = m_pFileStream->Tell(); + break; + case IResultSetHelper::PRIOR: + --m_nRowPos; + if(m_nRowPos > 0) + { + m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + m_nRowPos = 0; + + break; + case IResultSetHelper::LAST: + if(m_nMaxRowCount) + { + m_nFilePos = m_aRowToFilePos.rbegin()->second; + m_nRowPos = m_aRowToFilePos.rbegin()->first; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + { + while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row + // now I know all + seekRow(IResultSetHelper::PRIOR,1,nCurPos); + } + break; + case IResultSetHelper::RELATIVE: + if(nOffset > 0) + { + for(sal_Int32 i = 0;i::const_iterator aIter = m_aRowToFilePos.find(nOffset); + if(aIter != m_aRowToFilePos.end()) + { + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table + { + m_nRowPos = m_nMaxRowCount; + return sal_False; + } + else + { + aIter = m_aRowToFilePos.upper_bound(nOffset); + if(aIter == m_aRowToFilePos.end()) + { + m_nRowPos = m_aRowToFilePos.rbegin()->first; + nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; + while(m_nRowPos != nOffset) + seekRow(IResultSetHelper::NEXT,1,nCurPos); + } + else + { + --aIter; + m_nRowPos = aIter->first; + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + } + } + + break; + case IResultSetHelper::BOOKMARK: + m_pFileStream->Seek(nOffset); + if (m_pFileStream->IsEof()) + return sal_False; + + m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + break; + } + + //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); + + return sal_True; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LTable.hxx b/connectivity/source/drivers/evoab/LTable.hxx new file mode 100644 index 000000000000..360e4487cf09 --- /dev/null +++ b/connectivity/source/drivers/evoab/LTable.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LTable.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LTABLE_HXX_ +#define _CONNECTIVITY_EVOAB_LTABLE_HXX_ + +#include "file/FTable.hxx" +#include "connectivity/sdbcx/VColumn.hxx" +#include "connectivity/CommonTools.hxx" +#include +#include "file/quotedstring.hxx" +#include + +namespace connectivity +{ + namespace evoab + { + typedef file::OFileTable OEvoabTable_BASE; + class OEvoabConnection; + + typedef ::std::map< ::rtl::OUString, + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer; + + class OEvoabTable : public OEvoabTable_BASE + { + private: + // maps a row postion to a file position + ::std::map m_aRowToFilePos; + ::std::vector m_aTypes; // holds all type for columns just to avoid to ask the propertyset + ::std::vector m_aPrecisions; // same as aboth + ::std::vector m_aScales; + QuotedTokenizedString m_aCurrentLine; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter; + sal_Int32 m_nRowPos; + sal_Int32 m_nMaxRowCount; // will be set if stream is once eof + ::std::vector< ::rtl::OUString> m_aColumnRawNames; + sal_Bool setColumnAliases(); + void fillColumns(const ::com::sun::star::lang::Locale& _aLocale); + sal_Bool checkHeaderLine(); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet> isUniqueByColumnName(const ::rtl::OUString& _rColName); + + public: + virtual void refreshColumns(); + virtual void refreshIndexes(); + + public: + // DECLARE_CTY_DEFAULTS( OFlatTable_BASE); + OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection); + OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + void construct(); // can throw any exception + + virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos); + virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing(void); + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + String getEntry(); + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LTABLE_HXX_ + diff --git a/connectivity/source/drivers/evoab/LTables.cxx b/connectivity/source/drivers/evoab/LTables.cxx new file mode 100644 index 000000000000..7465c890f240 --- /dev/null +++ b/connectivity/source/drivers/evoab/LTables.cxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LTables.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "LTables.hxx" +#include "LTable.hxx" +#include +#include +#include +#include +#include +#include "file/FCatalog.hxx" +#include "file/FConnection.hxx" +#include + +using namespace connectivity; +using namespace ::comphelper; +using namespace connectivity::evoab; +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +namespace starutil = ::com::sun::star::util; + +sdbcx::ObjectType OEvoabTables::createObject(const ::rtl::OUString& _rName) +{ + OEvoabTable* pRet = new OEvoabTable(this,(OEvoabConnection*)static_cast(m_rParent).getConnection(), + _rName,::rtl::OUString::createFromAscii("TABLE")); + sdbcx::ObjectType xRet = pRet; + pRet->construct(); + return xRet; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/evoab/LTables.hxx b/connectivity/source/drivers/evoab/LTables.hxx new file mode 100644 index 000000000000..3fcaaa7d8e58 --- /dev/null +++ b/connectivity/source/drivers/evoab/LTables.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LTables.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_EVOAB_LTABLES_HXX_ +#define _CONNECTIVITY_EVOAB_LTABLES_HXX_ + +#include "file/FTables.hxx" + +namespace connectivity +{ + namespace evoab + { + // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx; + typedef file::OTables OEvoabTables_BASE; + + class OEvoabTables : public OEvoabTables_BASE + { + protected: + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + public: + OEvoabTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const TStringVector &_rVector) : OEvoabTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) + {} + }; + } +} +#endif // _CONNECTIVITY_EVOAB_LTABLES_HXX_ + diff --git a/connectivity/source/drivers/evoab/evoab.map b/connectivity/source/drivers/evoab/evoab.map new file mode 100644 index 000000000000..00cf7191f143 --- /dev/null +++ b/connectivity/source/drivers/evoab/evoab.map @@ -0,0 +1,8 @@ +EVOAB_1_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/connectivity/source/drivers/evoab/evoab.xcu b/connectivity/source/drivers/evoab/evoab.xcu new file mode 100755 index 000000000000..4c5c4894e0ab --- /dev/null +++ b/connectivity/source/drivers/evoab/evoab.xcu @@ -0,0 +1,64 @@ + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Evolution LDAP + + + + + true + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Groupwise + + + + + true + + + + + + diff --git a/connectivity/source/drivers/evoab/evoab.xml b/connectivity/source/drivers/evoab/evoab.xml new file mode 100644 index 000000000000..8ed16719ae0e --- /dev/null +++ b/connectivity/source/drivers/evoab/evoab.xml @@ -0,0 +1,33 @@ + + + + file + + Xibei(Berry) Jia + com.sun.star.comp.sdbc.evoab.OEvoabDriver + This library implements the database driver for evolution address book formats. + + com.sun.star.loader.SharedLibrary + c++ + + com.sun.star.sdbc.Driver + com.sun.star.sdbcx.Driver + ... + + cppuhelper + cppu + sal + vos + file + cppuhelper + cppu + sal + vos + osl + svtools-light1 + svtools + ucbhelper + dbtools + unotools + comphelper + diff --git a/connectivity/source/drivers/evoab/exports.dxp b/connectivity/source/drivers/evoab/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/evoab/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/evoab/makefile.mk b/connectivity/source/drivers/evoab/makefile.mk new file mode 100644 index 000000000000..8982322513de --- /dev/null +++ b/connectivity/source/drivers/evoab/makefile.mk @@ -0,0 +1,108 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.9 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=evoab + +VISIBILITY_HIDDEN=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : $(PRJ)$/version.mk +.INCLUDE : $(PRJ)$/makefile.pmk + +.IF "$(GUI)"=="UNX" + +# --- Files ------------------------------------- + +EXCEPTIONSFILES=\ + $(SLO)$/LResultSet.obj \ + $(SLO)$/LStatement.obj \ + $(SLO)$/LPreparedStatement.obj \ + $(SLO)$/LFolderList.obj \ + $(SLO)$/LConfigAccess.obj \ + $(SLO)$/LColumnAlias.obj \ + $(SLO)$/LTable.obj \ + $(SLO)$/LDatabaseMetaData.obj \ + $(SLO)$/LCatalog.obj \ + $(SLO)$/LColumns.obj \ + $(SLO)$/LTables.obj \ + $(SLO)$/LConnection.obj \ + $(SLO)$/LServices.obj \ + $(SLO)$/LDriver.obj + +SLOFILES=\ + $(EXCEPTIONSFILES) \ + $(SLO)$/LDebug.obj + + +SHL1VERSIONMAP=$(TARGET).map + + +# --- Library ----------------------------------- +#SHL1TARGET=$(TARGET)$(DLLPOSTFIX) +SHL1TARGET= $(EVOAB_TARGET)$(DLLPOSTFIX) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(TOOLSLIB) \ + $(SVTOOLLIB) \ + $(UNOTOOLSLIB) \ + $(UCBHELPERLIB) \ + $(SALLIB) \ + $(DBTOOLSLIB) \ + $(DBFILELIB) \ + $(COMPHELPERLIB) + +.IF "$(DBFILELIB)" == "" +SHL1STDLIBS+= ifile.lib +.ENDIF + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) + +.ELSE +dummy: + @echo "Nothing to build for GUI $(GUI)" +.ENDIF +# --- Targets ---------------------------------- +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/evoab2/evoab2.xcu b/connectivity/source/drivers/evoab2/evoab2.xcu new file mode 100755 index 000000000000..ddfc3b070e81 --- /dev/null +++ b/connectivity/source/drivers/evoab2/evoab2.xcu @@ -0,0 +1,79 @@ + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Evolution Local + + + + + true + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Evolution LDAP + + + + + true + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Groupwise + + + + + true + + + + + + diff --git a/connectivity/source/drivers/evoab2/makefile.mk b/connectivity/source/drivers/evoab2/makefile.mk index a911bd262516..e9bb9fdc4d70 100644 --- a/connectivity/source/drivers/evoab2/makefile.mk +++ b/connectivity/source/drivers/evoab2/makefile.mk @@ -39,7 +39,7 @@ dummy: # --- Settings ---------------------------------- -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk PKGCONFIG_MODULES=gtk+-2.0 @@ -111,4 +111,4 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/file/FStringFunctions.cxx b/connectivity/source/drivers/file/FStringFunctions.cxx index e3eeb52f2d7d..07e620763b79 100644 --- a/connectivity/source/drivers/file/FStringFunctions.cxx +++ b/connectivity/source/drivers/file/FStringFunctions.cxx @@ -32,6 +32,7 @@ #include "precompiled_connectivity.hxx" #include "file/FStringFunctions.hxx" +#include #include using namespace connectivity; @@ -102,7 +103,7 @@ ORowSetValue OOp_Concat::operate(const ::std::vector& lhs) const if ( lhs.empty() ) return ORowSetValue(); - ::rtl::OUString sRet; + ::rtl::OUStringBuffer sRet; ::std::vector::const_reverse_iterator aIter = lhs.rbegin(); ::std::vector::const_reverse_iterator aEnd = lhs.rend(); for (; aIter != aEnd; ++aIter) @@ -110,10 +111,10 @@ ORowSetValue OOp_Concat::operate(const ::std::vector& lhs) const if ( aIter->isNull() ) return ORowSetValue(); - sRet += *aIter; + sRet.append(aIter->operator ::rtl::OUString()); } - return sRet; + return sRet.makeStringAndClear(); } //------------------------------------------------------------------ ORowSetValue OOp_Locate::operate(const ::std::vector& lhs) const @@ -183,13 +184,13 @@ ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const return lhs; const sal_Char c = ' '; - ::rtl::OUString sRet; + ::rtl::OUStringBuffer sRet; sal_Int32 nCount = lhs; for (sal_Int32 i=0; i < nCount; ++i) { - sRet += ::rtl::OUString(&c,1,RTL_TEXTENCODING_ASCII_US); + sRet.appendAscii(&c,1); } - return sRet; + return sRet.makeStringAndClear(); } //------------------------------------------------------------------ ORowSetValue OOp_Replace::operate(const ::std::vector& lhs) const diff --git a/connectivity/source/drivers/flat/flat.xcu b/connectivity/source/drivers/flat/flat.xcu new file mode 100755 index 000000000000..e70996e8ffa0 --- /dev/null +++ b/connectivity/source/drivers/flat/flat.xcu @@ -0,0 +1,113 @@ + + + + + + + com.sun.star.comp.sdbc.flat.ODriver + + + Text + + + + + + + + + + + + + + + true + + + + + , + + + + + " + + + + + . + + + + + + + + + + false + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + application/csv + + + + + + diff --git a/connectivity/source/drivers/flat/makefile.mk b/connectivity/source/drivers/flat/makefile.mk index 0cc44de7c55e..d044eab2796a 100644 --- a/connectivity/source/drivers/flat/makefile.mk +++ b/connectivity/source/drivers/flat/makefile.mk @@ -41,7 +41,7 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk @@ -106,6 +106,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/hsqldb/hsqldb.xcu b/connectivity/source/drivers/hsqldb/hsqldb.xcu new file mode 100755 index 000000000000..8fbee4f4c00a --- /dev/null +++ b/connectivity/source/drivers/hsqldb/hsqldb.xcu @@ -0,0 +1,76 @@ + + + + + + + com.sun.star.sdbcx.comp.hsqldb.Driver + + + HSQL database engine + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + diff --git a/connectivity/source/drivers/hsqldb/makefile.mk b/connectivity/source/drivers/hsqldb/makefile.mk index a97365a4d835..9ed5acb17d4c 100644 --- a/connectivity/source/drivers/hsqldb/makefile.mk +++ b/connectivity/source/drivers/hsqldb/makefile.mk @@ -39,7 +39,7 @@ VISIBILITY_HIDDEN=TRUE USE_DEFFILE=TRUE # --- Settings ---------------------------------- -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk .IF "$(SOLAR_JAVA)"=="" @@ -115,6 +115,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu new file mode 100755 index 000000000000..73fe2e9adc55 --- /dev/null +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -0,0 +1,207 @@ + + + + + + + com.sun.star.comp.sdbc.JDBCDriver + + + JDBC + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + + jdbc:* + + + Oracle JDBC + + + + + false + + + + + Column(2) = -5,Column(6) = PRECISION,Column(2) = -4,Column(6) = PRECISION,Column(2) = -3,Column(6) = PRECISION,Column(2) = -2,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = 2,Column(6) = PRECISION,Column(2) = 12,Column(6) = PRECISION + + + + + oracle.jdbc.driver.OracleDriver + + + + + + + true + + + + + + + UserPassword + + + + + + diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk index b8d6a54dd065..831a6755af91 100644 --- a/connectivity/source/drivers/jdbc/makefile.mk +++ b/connectivity/source/drivers/jdbc/makefile.mk @@ -42,7 +42,7 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk @@ -110,6 +110,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 6f50a6b1affd..daaed46acdd9 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -150,6 +150,9 @@ java_util_Properties* connectivity::createStringPropertyArray(const Sequence< Pr && pBegin->Name.compareToAscii( "IgnoreDriverPrivileges" ) && pBegin->Name.compareToAscii( "ImplicitCatalogRestriction" ) && pBegin->Name.compareToAscii( "ImplicitSchemaRestriction" ) + && pBegin->Name.compareToAscii( "SupportsTableCreation" ) + && pBegin->Name.compareToAscii( "UseJava" ) + && pBegin->Name.compareToAscii( "Authentication" ) ) { ::rtl::OUString aStr; diff --git a/connectivity/source/drivers/kab/kab.xcu b/connectivity/source/drivers/kab/kab.xcu new file mode 100755 index 000000000000..cc8e6b5329b5 --- /dev/null +++ b/connectivity/source/drivers/kab/kab.xcu @@ -0,0 +1,49 @@ + + + + + + + com.sun.star.comp.sdbc.kab.Driver + + + KDE Address Book + + + + + true + + + + + + diff --git a/connectivity/source/drivers/kab/makefile.mk b/connectivity/source/drivers/kab/makefile.mk index 4ee330345625..2c0a86f8562b 100644 --- a/connectivity/source/drivers/kab/makefile.mk +++ b/connectivity/source/drivers/kab/makefile.mk @@ -40,7 +40,7 @@ VISIBILITY_HIDDEN=TRUE # --- Settings ---------------------------------- -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk .IF "$(GUI)" == "UNX" @@ -137,5 +137,5 @@ dummy: @echo "Nothing to build for GUI $(GUI)" .ENDIF -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/macab/macab.xcu b/connectivity/source/drivers/macab/macab.xcu new file mode 100755 index 000000000000..3818c7db882b --- /dev/null +++ b/connectivity/source/drivers/macab/macab.xcu @@ -0,0 +1,49 @@ + + + + + + + com.sun.star.comp.sdbc.macab.Driver + + + Mac OS X Address Book + + + + + true + + + + + + diff --git a/connectivity/source/drivers/macab/makefile.mk b/connectivity/source/drivers/macab/makefile.mk index 67f40f2d45cf..8edc8951fa95 100755 --- a/connectivity/source/drivers/macab/makefile.mk +++ b/connectivity/source/drivers/macab/makefile.mk @@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ---------------------------------- -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk .IF "$(GUI)" == "UNX" @@ -133,5 +133,5 @@ dummy: @echo "Nothing to build for GUI $(GUI)" .ENDIF -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/mozab/makefile.mk b/connectivity/source/drivers/mozab/makefile.mk index a842c75c7a72..e546f5a3682d 100644 --- a/connectivity/source/drivers/mozab/makefile.mk +++ b/connectivity/source/drivers/mozab/makefile.mk @@ -89,11 +89,24 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk # --- Files ------------------------------------- +# redefine because win and linux differ +.IF "$(OS)"=="WNT" +LOCALIZEDFILES= \ + $(TARGET).xcu +.ELSE +LOCALIZEDFILES= \ + $(TARGET)2.xcu +.ENDIF + +XCUFILES= \ + $(LOCALIZEDFILES) \ + + SLOFILES=\ $(SLO)$/MDriver.obj \ @@ -186,7 +199,18 @@ DEF2NAME= $(SHL2TARGET) # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk + +.IF "$(GUI)"=="WNT" +.ELSE +ALLTAR: "$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(TARGET)2.xcs" "$(PWD)$/$(MISC)$/registry$/data$/$(PACKAGEDIR)$/$(TARGET).xcu" +"$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(TARGET)2.xcs" : $(SOLARXMLDIR)$/registry$/schema$/$(PACKAGEDIR)$/Drivers.xcs + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ +"$(PWD)$/$(MISC)$/registry$/data$/$(PACKAGEDIR)$/$(TARGET).xcu" : "$(PWD)$/$(MISC)$/registry$/data$/$(PACKAGEDIR)$/$(TARGET)2.xcu" + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ +.ENDIF # --- filter file ------------------------------ diff --git a/connectivity/source/drivers/mozab/mozab.xcu b/connectivity/source/drivers/mozab/mozab.xcu new file mode 100755 index 000000000000..f47e1708e690 --- /dev/null +++ b/connectivity/source/drivers/mozab/mozab.xcu @@ -0,0 +1,157 @@ + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Microsoft Outlook Address Book + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Microsoft Windows Address Book + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Mozilla Address Book + + + + + true + + + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Thunderbird Address Book + + + + + true + + + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + LDAP Address Book + + + + + + + + + + 100 + + + + + 389 + + + + + false + + + + + + + true + + + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/source/drivers/mozab/mozab2.xcu b/connectivity/source/drivers/mozab/mozab2.xcu new file mode 100755 index 000000000000..41d99391c540 --- /dev/null +++ b/connectivity/source/drivers/mozab/mozab2.xcu @@ -0,0 +1,121 @@ + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Mozilla Address Book + + + + + true + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + Thunderbird Address Book + + + + + true + + + + + true + + + + + + + com.sun.star.comp.sdbc.MozabDriver + + + LDAP Address Book + + + + + + + + + + 100 + + + + + 389 + + + + + false + + + + + + + true + + + + + UserPassword + + + + + true + + + + + + diff --git a/connectivity/source/drivers/mysql/makefile.mk b/connectivity/source/drivers/mysql/makefile.mk index 9a24864a9bba..0d46f0c35dbb 100644 --- a/connectivity/source/drivers/mysql/makefile.mk +++ b/connectivity/source/drivers/mysql/makefile.mk @@ -42,7 +42,7 @@ VISIBILITY_HIDDEN=TRUE ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk @@ -83,6 +83,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/mysql/mysql.xcu b/connectivity/source/drivers/mysql/mysql.xcu new file mode 100755 index 000000000000..c730df2af5c7 --- /dev/null +++ b/connectivity/source/drivers/mysql/mysql.xcu @@ -0,0 +1,177 @@ + + + + + + + org.openoffice.comp.drivers.MySQL.Driver + + + MySQL (JDBC) + + + + + + + + + + com.mysql.jdbc.Driver + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + + org.openoffice.comp.drivers.MySQL.Driver + + + MySQL (ODBC) + + + + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/source/drivers/odbc/makefile.mk b/connectivity/source/drivers/odbc/makefile.mk index f84f2a725d67..8f37b6185d5e 100644 --- a/connectivity/source/drivers/odbc/makefile.mk +++ b/connectivity/source/drivers/odbc/makefile.mk @@ -45,7 +45,7 @@ LDUMP=ldump2.exe ENVCFLAGS+=/FR$(SLO)$/ .ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk .IF "$(SYSTEM_ODBC_HEADERS)" == "YES" @@ -79,4 +79,4 @@ SHL1VERSIONMAP=odbc.map # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu new file mode 100755 index 000000000000..cf306f10d57f --- /dev/null +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -0,0 +1,173 @@ + + + + + + + com.sun.star.comp.sdbc.ODBCDriver + + + ODBC + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + false + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index ce03fa325019..f72aec64e7dc 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -37,6 +37,8 @@ #include "odbc/OConnection.hxx" #include "diagnose_ex.h" #include +#include + #include #include @@ -544,7 +546,7 @@ Sequence OTools::getBytesValue(OConnection* _pConnection, rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getStringValue" ); - ::rtl::OUString aData; + ::rtl::OUStringBuffer aData; switch(_fSqlType) { case SQL_WVARCHAR: @@ -599,7 +601,7 @@ Sequence OTools::getBytesValue(OConnection* _pConnection, nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1); waCharArray[nLen] = 0; - aData += ::rtl::OUString(waCharArray); + aData.append(::rtl::OUString(waCharArray)); } } break; @@ -648,7 +650,7 @@ Sequence OTools::getBytesValue(OConnection* _pConnection, --nLen; aCharArray[nLen] = 0; - aData += ::rtl::OUString((const sal_Char*)aCharArray,nLen,_nTextEncoding); + aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen,_nTextEncoding)); } // delete all blanks @@ -656,7 +658,7 @@ Sequence OTools::getBytesValue(OConnection* _pConnection, } } - return aData; + return aData.makeStringAndClear(); } // ------------------------------------------------------------------------- void OTools::GetInfo(OConnection* _pConnection, diff --git a/connectivity/source/manager/makefile.mk b/connectivity/source/manager/makefile.mk index ce16b2f887d8..7cb514cd3696 100644 --- a/connectivity/source/manager/makefile.mk +++ b/connectivity/source/manager/makefile.mk @@ -35,6 +35,7 @@ PRJNAME=connectivity TARGET=sdbc ENABLE_EXCEPTIONS=TRUE +VISIBILITY_HIDDEN=TRUE # --- Settings ---------------------------------- .IF "$(DBGUTIL_OJ)"!="" @@ -62,6 +63,8 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(COMPHELPERLIB) \ + $(DBTOOLSLIB) \ + $(UNOTOOLSLIB) \ $(SALLIB) SHL1DEPN= diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index 3cc251659854..d62f6294e5f8 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -278,13 +278,26 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W } }; + /// and STL argorithm compatible predicate comparing a DriverAccess' impl name to a string + struct EqualDriverAccessToName : public ::std::binary_function< DriverAccess, ::rtl::OUString, bool > + { + ::rtl::OUString m_sImplName; + EqualDriverAccessToName(const ::rtl::OUString& _sImplName) : m_sImplName(_sImplName){} + //................................................................. + bool operator()( const DriverAccess& lhs) + { + return lhs.sImplementationName.equals(m_sImplName); + } + }; + //========================================================================== //= OSDBCDriverManager //========================================================================== //-------------------------------------------------------------------------- - OSDBCDriverManager::OSDBCDriverManager( const Reference< XComponentContext >& _rxContext ) +OSDBCDriverManager::OSDBCDriverManager( const Reference< XComponentContext >& _rxContext ) :m_aContext( _rxContext ) ,m_aEventLogger( _rxContext, "org.openoffice.logging.sdbc.DriverManager" ) + ,m_aDriverConfig(m_aContext.getLegacyServiceFactory()) ,m_nLoginTimeout(0) { // bootstrap all objects supporting the .sdb.Driver service @@ -375,7 +388,7 @@ void OSDBCDriverManager::bootstrapDrivers() //-------------------------------------------------------------------------- void OSDBCDriverManager::initializeDriverPrecedence() { - if (!m_aDriversBS.size()) + if ( m_aDriversBS.empty() ) // nothing to do return; @@ -420,7 +433,7 @@ void OSDBCDriverManager::initializeDriverPrecedence() { // we have a DriverAccess with this impl name OSL_ENSURE( ::std::distance( aPos.first, aPos.second ) == 1, - "OSDBCDriverManager::initializeDriverPrecedence: move than one driver with this impl name? How this?" ); + "OSDBCDriverManager::initializeDriverPrecedence: more than one driver with this impl name? How this?" ); // move the DriverAccess pointed to by aPos.first to the position pointed to by aNoPrefDriversStart if ( aPos.first != aNoPrefDriversStart ) @@ -686,17 +699,29 @@ Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const ::rtl::OUStri Reference< XDriver > xReturn; { - // search all bootstrapped drivers - DriverAccessArrayIterator aPos = ::std::find_if( - m_aDriversBS.begin(), // begin of search range - m_aDriversBS.end(), // end of search range - std::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() ) - // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance - ); + const ::rtl::OUString sDriverFactoryName = m_aDriverConfig.getDriverFactoryName(_rURL); + + EqualDriverAccessToName aEqual(sDriverFactoryName); + DriverAccessArray::iterator aFind = ::std::find_if(m_aDriversBS.begin(),m_aDriversBS.end(),aEqual); + if ( aFind == m_aDriversBS.end() ) + { + // search all bootstrapped drivers + aFind = ::std::find_if( + m_aDriversBS.begin(), // begin of search range + m_aDriversBS.end(), // end of search range + std::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() ) + // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance + ); + } // if ( m_aDriversBS.find(sDriverFactoryName ) == m_aDriversBS.end() ) + else + { + EnsureDriver aEnsure; + aEnsure(*aFind); + } // found something? - if ( m_aDriversBS.end() != aPos ) - xReturn = aPos->xDriver; + if ( m_aDriversBS.end() != aFind ) + xReturn = aFind->xDriver; } if ( !xReturn.is() ) diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx index fef1e1b82429..369b8260f302 100644 --- a/connectivity/source/manager/mdrivermanager.hxx +++ b/connectivity/source/manager/mdrivermanager.hxx @@ -44,6 +44,7 @@ #include #include #include +#include "connectivity/DriversConfig.hxx" namespace drivermanager { @@ -81,16 +82,15 @@ namespace drivermanager ::comphelper::EventLogger m_aEventLogger; DECLARE_STL_VECTOR(DriverAccess, DriverAccessArray); - DriverAccessArray m_aDriversBS; + DriverAccessArray m_aDriversBS; // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface, // so we have to remember their impl-name in another way DECLARE_STL_USTRINGACCESS_MAP(SdbcDriver, DriverCollection); DriverCollection m_aDriversRT; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > - m_xServiceFactory; - sal_Int32 m_nLoginTimeout; + ::connectivity::DriversConfig m_aDriverConfig; + sal_Int32 m_nLoginTimeout; private: OSDBCDriverManager( diff --git a/connectivity/source/manager/mregistration.cxx b/connectivity/source/manager/mregistration.cxx index 89a7507600f7..4a305267df14 100644 --- a/connectivity/source/manager/mregistration.cxx +++ b/connectivity/source/manager/mregistration.cxx @@ -48,13 +48,13 @@ extern "C" { //--------------------------------------------------------------------------------------- - void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/) +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/) { *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //--------------------------------------------------------------------------------------- -sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey) +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey) { @@ -86,7 +86,7 @@ sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star } //--------------------------------------------------------------------------------------- -void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/) +SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/) { void* pRet = NULL; diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 5710d747a5f9..76c6c69d269c 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -304,9 +304,10 @@ void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString, if ( _rxConnection.is() ) { + ::rtl::OUStringBuffer sBuffer = rString; try { - OSQLParseNode::impl_parseNodeToString_throw( rString, + OSQLParseNode::impl_parseNodeToString_throw( sBuffer, SQLParseNodeParameter( _rxConnection, xFormatter, _xField, rIntl, pContext, _bIntl, _bQuote, _cDecSep, _bPredicate, _bSubstitute @@ -320,6 +321,7 @@ void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString, // in the sub queries, but this cannot be the case here, as we do not parse to // SDBC level. } + rString = sBuffer.makeStringAndClear(); } } //----------------------------------------------------------------------------- @@ -342,10 +344,11 @@ bool OSQLParseNode::parseNodeToExecutableStatement( ::rtl::OUString& _out_rStrin aParseParam.pParser = &_rParser; _out_rString = ::rtl::OUString(); + ::rtl::OUStringBuffer sBuffer; bool bSuccess = false; try { - impl_parseNodeToString_throw( _out_rString, aParseParam ); + impl_parseNodeToString_throw( sBuffer, aParseParam ); bSuccess = true; } catch( const SQLException& e ) @@ -353,6 +356,7 @@ bool OSQLParseNode::parseNodeToExecutableStatement( ::rtl::OUString& _out_rStrin if ( _pErrorHolder ) *_pErrorHolder = e; } + _out_rString = sBuffer.makeStringAndClear(); return bSuccess; } @@ -366,7 +370,7 @@ namespace } //----------------------------------------------------------------------------- -void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const +void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getTableRange" ); if ( isToken() ) @@ -385,19 +389,19 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const case parameter: { if(rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); + rString.appendAscii(" "); if (nCount == 1) // ? m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); else if (nCount == 2) // :Name { m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); - rString += m_aChildren[1]->m_aNodeValue; + rString.append(m_aChildren[1]->m_aNodeValue); } // [Name] else { m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); - rString += m_aChildren[1]->m_aNodeValue; - rString += m_aChildren[2]->m_aNodeValue; + rString.append(m_aChildren[1]->m_aNodeValue); + rString.append(m_aChildren[2]->m_aNodeValue); } bHandled = true; } @@ -419,7 +423,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const case as: if ( rParam.aMetaData.generateASBeforeCorrelationName() ) - rString += ::rtl::OUString::createFromAscii( " AS" ); + rString.append(::rtl::OUString::createFromAscii( " AS" )); bHandled = true; break; @@ -447,7 +451,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUString& rString, const m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam ); aNewParam.bQuote = rParam.bQuote; //aNewParam.bPredicate = sal_False; // disable [ ] around names // look at i73215 - ::rtl::OUString aStringPara; + ::rtl::OUStringBuffer aStringPara; for (sal_uInt32 i=1; iimpl_parseNodeToString_throw( sSubSelect, rParam ); if ( sSubSelect.getLength() ) - sCommand = sSubSelect; + sCommand = sSubSelect.makeStringAndClear(); } } - rString += ::rtl::OUString::createFromAscii( " ( " ); - rString += sCommand; - rString += ::rtl::OUString::createFromAscii( " )" ); + rString.appendAscii( " ( " ); + rString.append(sCommand); + rString.appendAscii( " )" ); // append the query name as table alias, since it might be referenced in other // parts of the statement - but only if there's no other alias name present if ( !lcl_isAliasNamePresent( *this ) ) { - rString += ::rtl::OUString::createFromAscii( " AS " ); + rString.appendAscii( " AS " ); if ( rParam.bQuote ) - rString += SetQuotation( sTableOrQueryName, - rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() ); + rString.append(SetQuotation( sTableOrQueryName, + rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() )); } // don't forget to remove the query name from the history, else multiple inclusions @@ -663,7 +666,7 @@ bool OSQLParseNode::impl_parseTableNameNodeToString_throw( ::rtl::OUString& rStr } //----------------------------------------------------------------------------- -void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const +void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::impl_parseTableRangeNodeToString_throw" ); OSL_PRECOND( ( count() == 2 ) || ( count() == 3 ) || ( count() == 5 ) ,"Illegal count"); @@ -674,7 +677,7 @@ void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUString& rStr } //----------------------------------------------------------------------------- -void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUString& rString, const SQLParseNodeParameter& rParam ) const +void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::impl_parseLikeNodeToString_throw" ); OSL_ENSURE(count() >= 4,"count != 5: Prepare for GPF"); @@ -725,8 +728,8 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUString& rString, if (pParaNode->isToken()) { ::rtl::OUString aStr = ConvertLikeToken(pParaNode, pEscNode, rParam.bInternational); - rString += ::rtl::OUString::createFromAscii(" "); - rString += SetQuotation(aStr,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'")); + rString.appendAscii(" "); + rString.append(SetQuotation(aStr,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'"))); } else pParaNode->impl_parseNodeToString_throw( rString, aNewParam ); @@ -1687,7 +1690,7 @@ void OSQLParseNode::append(OSQLParseNode* pNewNode) m_aChildren.push_back(pNewNode); } // ----------------------------------------------------------------------------- -sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const +sal_Bool OSQLParseNode::addDateValue(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::addDateValue" ); // special display for date/time values @@ -1708,10 +1711,6 @@ sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNod { suQuote = ::rtl::OUString::createFromAscii("#"); } - else - { - suQuote = ::rtl::OUString::createFromAscii("'"); - } } else { @@ -1720,29 +1719,25 @@ sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNod // suQuote = ::rtl::OUString::createFromAscii("'"); return sal_False; } - else - { - suQuote = ::rtl::OUString::createFromAscii("'"); - } } if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += suQuote; + rString.appendAscii(" "); + rString.append(suQuote); const ::rtl::OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue(); if (SQL_ISTOKEN(pODBCNodeChild, D)) { - rString += rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue; + rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue); } else if (SQL_ISTOKEN(pODBCNodeChild, T)) { - rString += rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue; + rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue); } else { - rString += rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue; + rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue); } - rString += suQuote; + rString.append(suQuote); return sal_True; } } @@ -2443,7 +2438,7 @@ OSQLParseNode* OSQLParseNode::replace (OSQLParseNode* pOldSubNode, OSQLParseNode return pOldSubNode; } // ----------------------------------------------------------------------------- -void OSQLParseNode::parseLeaf(::rtl::OUString & rString, const SQLParseNodeParameter& rParam) const +void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseLeaf" ); // ein Blatt ist gefunden @@ -2453,51 +2448,51 @@ void OSQLParseNode::parseLeaf(::rtl::OUString & rString, const SQLParseNodeParam case SQL_NODE_KEYWORD: { if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); + rString.appendAscii(" "); - ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, &rParam.m_rContext); - rString += ::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8); + const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, &rParam.m_rContext); + rString.append(::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8)); } break; case SQL_NODE_STRING: if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += SetQuotation(m_aNodeValue,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'")); + rString.appendAscii(" "); + rString.append(SetQuotation(m_aNodeValue,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'"))); break; case SQL_NODE_NAME: if (rString.getLength()) { - switch(rString.getStr()[rString.getLength()-1] ) + switch(rString.charAt(rString.getLength()-1) ) { case ' ' : case '.' : break; default : if ( !rParam.aMetaData.getCatalogSeparator().getLength() - || rString.getStr()[ rString.getLength()-1 ] != rParam.aMetaData.getCatalogSeparator().toChar() + || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar() ) - rString += ::rtl::OUString::createFromAscii(" "); break; + rString.appendAscii(" "); break; } } if (rParam.bQuote) { if (rParam.bPredicate) { - rString+= ::rtl::OUString::createFromAscii("["); - rString += m_aNodeValue; - rString+= ::rtl::OUString::createFromAscii("]"); + rString.appendAscii("["); + rString.append(m_aNodeValue); + rString.appendAscii("]"); } else - rString += SetQuotation(m_aNodeValue, - rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() ); + rString.append(SetQuotation(m_aNodeValue, + rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() )); } else - rString += m_aNodeValue; + rString.append(m_aNodeValue); break; case SQL_NODE_ACCESS_DATE: if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += ::rtl::OUString::createFromAscii("#"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("#"); + rString.appendAscii(" "); + rString.appendAscii("#"); + rString.append(m_aNodeValue); + rString.appendAscii("#"); break; case SQL_NODE_INTNUM: case SQL_NODE_APPROXNUM: @@ -2507,26 +2502,26 @@ void OSQLParseNode::parseLeaf(::rtl::OUString & rString, const SQLParseNodeParam aTmp = aTmp.replace('.', rParam.cDecSep); if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += aTmp; + rString.appendAscii(" "); + rString.append(aTmp); } break; // fall through default: if (rString.getLength() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' ) { - switch( rString.getStr()[rString.getLength()-1] ) + switch( rString.charAt(rString.getLength()-1) ) { case ' ' : case '.' : break; default : if ( !rParam.aMetaData.getCatalogSeparator().getLength() - || rString.getStr()[ rString.getLength()-1 ] != rParam.aMetaData.getCatalogSeparator().toChar() + || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar() ) - rString += ::rtl::OUString::createFromAscii(" "); break; + rString.appendAscii(" "); break; } } - rString += m_aNodeValue; + rString.append(m_aNodeValue); } } diff --git a/connectivity/target.pmk b/connectivity/target.pmk new file mode 100755 index 000000000000..8d6dedaf7927 --- /dev/null +++ b/connectivity/target.pmk @@ -0,0 +1,37 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.pmk,v $ +# +# $Revision: 1.6 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.INCLUDE : target.mk + +ALLTAR: "$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(TARGET).xcs" +"$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(TARGET).xcs" : $(SOLARXMLDIR)$/registry$/schema$/$(PACKAGEDIR)$/Drivers.xcs + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ diff --git a/connectivity/util/delzip b/connectivity/util/delzip new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/connectivity/util/langfilter.xsl b/connectivity/util/langfilter.xsl new file mode 100755 index 000000000000..76cfcff20ac6 --- /dev/null +++ b/connectivity/util/langfilter.xsl @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/connectivity/util/makefile.mk b/connectivity/util/makefile.mk new file mode 100755 index 000000000000..805aa0110f6f --- /dev/null +++ b/connectivity/util/makefile.mk @@ -0,0 +1,80 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.22 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = .. +TARGET = connectivity +PRJNAME = connectivity + +# ----------------------------------------------------------------------------- +# include global settings +# ----------------------------------------------------------------------------- + +.INCLUDE : settings.mk + +DIR_FILTERCFGOUT := $(MISC)$/drivers +DIR_LANGPACK := $(DIR_FILTERCFGOUT) +.IF "$(WITH_LANG)"!="" +DIR_LANG_SOURCE := $(MISC)$/merge +.ELSE +DIR_LANG_SOURCE := $(MISC)$/registry$/data +.ENDIF +DRIVER_MERGE_XCU := $(shell -@$(FIND) $(DIR_LANG_SOURCE)$/org$/openoffice$/Office$/DataAccess -name "*.xcu") + +REALFILTERPACKAGES_FILTERS_UI_LANGPACKS = \ + $(foreach,i,$(alllangiso) $(foreach,j,$(DRIVER_MERGE_XCU) $(DIR_LANGPACK)$/$i$/org$/openoffice$/Office$/DataAccess$/$(j:f))) + +.INCLUDE: target.mk + +PACKLANG := $(XSLTPROC) --nonet +PACKLANG_IN := +PACKLANG_PARAM := --stringparam +PACKLANG_XSL := + +$(REALFILTERPACKAGES_FILTERS_UI_LANGPACKS) : + @echo =================================================================== + @echo Building language package for driver $(@:b:s/Filter_//) + @echo =================================================================== + +-$(MKDIRHIER) $(@:d) + $(PACKLANG) $(PACKLANG_PARAM) lang $(@:d:d:d:d:d:d:d:d:d:d:b) $(PACKLANG_XSL) langfilter.xsl $(PACKLANG_IN) $(DIR_LANG_SOURCE)$/org$/openoffice$/Office$/DataAccess$/$(@:f) > $@ + +$(MISC)$/$(TARGET)_delzip : + -$(RM) $(BIN)$/fcfg_drivers_{$(alllangiso)}.zip + +$(BIN)$/fcfg_drivers_{$(alllangiso)}.zip : $(REALFILTERPACKAGES_FILTERS_UI_LANGPACKS) + cd $(DIR_FILTERCFGOUT)$/$(@:b:s/fcfg_drivers_//) && zip -ru ..$/..$/..$/bin$/fcfg_drivers_$(@:b:s/fcfg_drivers_//).zip org/* +.IF "$(USE_SHELL)"!="4nt" + $(PERL) -w $(SOLARENV)$/bin$/cleanzip.pl $@ +.ENDIF # "$(USE_SHELL)"!="4nt" + +ALLTAR: \ + $(MISC)$/$(TARGET)_delzip \ + $(BIN)$/fcfg_drivers_{$(alllangiso)}.zip + diff --git a/officecfg/prj/build.lst b/officecfg/prj/build.lst index b128b44751ec..dba837c643a7 100644 --- a/officecfg/prj/build.lst +++ b/officecfg/prj/build.lst @@ -1,17 +1,18 @@ oc officecfg : l10n soltools solenv LIBXSLT:libxslt NULL -oc officecfg usr30073 - none NULL -oc officecfg usr1 - all oc_mkout NULL -oc officecfg\registry\schema nmake - all oc_reg_schema NULL -oc officecfg\registry nmake - all oc_reg NULL -oc officecfg\registry\schema\org\openoffice nmake - all oc_reg_schema_ooo NULL -oc officecfg\registry\schema\org\openoffice\Office nmake - all oc_reg_schema_ooo_office NULL -oc officecfg\registry\schema\org\openoffice\Office\UI nmake - all oc_reg_schema_ooo_office_ui NULL -oc officecfg\registry\schema\org\openoffice\Office\OOoImprovement nmake - all oc_reg_schema_ooo_office_oooimprovement NULL -oc officecfg\registry\schema\org\openoffice\TypeDetection nmake - all oc_reg_schema_ooo_td NULL -oc officecfg\registry\schema\org\openoffice\ucb nmake - all oc_reg_schema_ooo_ucb NULL -oc officecfg\registry\data\org\openoffice nmake - all oc_reg_data_ooo oc_reg NULL -oc officecfg\registry\data\org\openoffice\Office nmake - all oc_reg_data_ooo_office oc_reg NULL -oc officecfg\registry\data\org\openoffice\Office\UI nmake - all oc_reg_data_ooo_office_ui oc_reg NULL -oc officecfg\registry\data\org\openoffice\TypeDetection nmake - all oc_reg_data_ooo_td oc_reg NULL -oc officecfg\registry\data\org\openoffice\ucb nmake - all oc_reg_data_ooo_ucb oc_reg NULL -oc officecfg\util nmake - all oc_util oc_reg_schema oc_reg_schema_ooo oc_reg_schema_ooo_office oc_reg_schema_ooo_office_ui oc_reg_schema_ooo_office_oooimprovement oc_reg_schema_ooo_td oc_reg_schema_ooo_ucb oc_reg_data_ooo oc_reg_data_ooo_office oc_reg_data_ooo_office_ui oc_reg_data_ooo_td oc_reg_data_ooo_ucb NULL +oc officecfg usr30073 - none NULL +oc officecfg usr1 - all oc_mkout NULL +oc officecfg\registry\schema nmake - all oc_reg_schema NULL +oc officecfg\registry nmake - all oc_reg NULL +oc officecfg\registry\schema\org\openoffice nmake - all oc_reg_schema_ooo NULL +oc officecfg\registry\schema\org\openoffice\Office nmake - all oc_reg_schema_ooo_office NULL +oc officecfg\registry\schema\org\openoffice\Office\UI nmake - all oc_reg_schema_ooo_office_ui NULL +oc officecfg\registry\schema\org\openoffice\Office\DataAccess nmake - all oc_reg_schema_ooo_office_dataaccess NULL +oc officecfg\registry\schema\org\openoffice\Office\OOoImprovement nmake - all oc_reg_schema_ooo_office_oooimprovement NULL +oc officecfg\registry\schema\org\openoffice\TypeDetection nmake - all oc_reg_schema_ooo_td NULL +oc officecfg\registry\schema\org\openoffice\ucb nmake - all oc_reg_schema_ooo_ucb NULL +oc officecfg\registry\data\org\openoffice nmake - all oc_reg_data_ooo oc_reg NULL +oc officecfg\registry\data\org\openoffice\Office nmake - all oc_reg_data_ooo_office oc_reg NULL +oc officecfg\registry\data\org\openoffice\Office\UI nmake - all oc_reg_data_ooo_office_ui oc_reg NULL +oc officecfg\registry\data\org\openoffice\TypeDetection nmake - all oc_reg_data_ooo_td oc_reg NULL +oc officecfg\registry\data\org\openoffice\ucb nmake - all oc_reg_data_ooo_ucb oc_reg NULL +oc officecfg\util nmake - all oc_util oc_reg_schema oc_reg_schema_ooo oc_reg_schema_ooo_office oc_reg_schema_ooo_office_ui oc_reg_schema_ooo_office_dataaccess oc_reg_schema_ooo_office_oooimprovement oc_reg_schema_ooo_td oc_reg_schema_ooo_ucb oc_reg_data_ooo oc_reg_data_ooo_office oc_reg_data_ooo_office_ui oc_reg_data_ooo_td oc_reg_data_ooo_ucb NULL diff --git a/officecfg/prj/d.lst b/officecfg/prj/d.lst index d36f18660611..66ba41abd60e 100644 --- a/officecfg/prj/d.lst +++ b/officecfg/prj/d.lst @@ -4,6 +4,7 @@ mkdir: %_DEST%\xml%_EXT%\registry\schema\org mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\UI +mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\DataAccess mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\OOoImprovement mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\ucb mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\TypeDetection @@ -11,6 +12,7 @@ mkdir: %_DEST%\xml%_EXT%\registry\schema\org\openoffice\TypeDetection ..\%__SRC%\misc\registry\schema\org\openoffice\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice ..\%__SRC%\misc\registry\schema\org\openoffice\Office\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office ..\%__SRC%\misc\registry\schema\org\openoffice\Office\UI\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\UI +..\%__SRC%\misc\registry\schema\org\openoffice\Office\DataAccess\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\DataAccess ..\%__SRC%\misc\registry\schema\org\openoffice\Office\OOoImprovement\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\Office\OOoImprovement ..\%__SRC%\misc\registry\schema\org\openoffice\ucb\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\ucb ..\%__SRC%\misc\registry\schema\org\openoffice\TypeDetection\*.xcs %_DEST%\xml%_EXT%\registry\schema\org\openoffice\TypeDetection @@ -20,6 +22,7 @@ mkdir: %_DEST%\xml%_EXT%\registry\data\org mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\UI +mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\DataAccess mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\OOoImprovement mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\ucb mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\TypeDetection @@ -32,6 +35,7 @@ mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\TypeDetection ..\%__SRC%\misc\registry\data\org\openoffice\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice ..\%__SRC%\misc\registry\data\org\openoffice\Office\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office ..\%__SRC%\misc\registry\data\org\openoffice\Office\UI\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\UI +..\%__SRC%\misc\registry\data\org\openoffice\Office\DataAccess\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\DataAccess ..\%__SRC%\misc\registry\data\org\openoffice\ucb\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\ucb ..\%__SRC%\misc\registry\data\org\openoffice\TypeDetection\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\TypeDetection diff --git a/officecfg/registry/schema/org/openoffice/Office/DataAccess/Drivers.xcs b/officecfg/registry/schema/org/openoffice/Office/DataAccess/Drivers.xcs new file mode 100755 index 000000000000..d0b54e71498b --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/Office/DataAccess/Drivers.xcs @@ -0,0 +1,100 @@ + + + + + + Contains the installed OpenOffice.org Base database drivers. + + + + + Describes a property of a driver. + + + + Describes the value. + + + + + + Describes a feature a driver supports. + + + + The feature value. + + + + + + Specifies a database driver. + + + + Specifies the URL pattern of the parent which settings should be used if not present. + + + + + Specifies the factory name of the database driver. + + + + + Specifies the UI name of the database driver. + + + + + Defines a list of all properties which are different from default. + + + + + Defines a list of all properties which are different from default. + + + + + Defines a list of all meta data properties which the database application should supports. + + + + + + + + Contains a list of URLs supported by installed database drivers. + + + + diff --git a/officecfg/registry/schema/org/openoffice/Office/DataAccess/makefile.mk b/officecfg/registry/schema/org/openoffice/Office/DataAccess/makefile.mk new file mode 100755 index 000000000000..906bbe5108e9 --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/Office/DataAccess/makefile.mk @@ -0,0 +1,46 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: $ +# +# $Revision: $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/..$/..$/..$/..$/.. + +PRJNAME=officecfg +TARGET=schema_ooODataAccess +PACKAGE=org.openoffice.Office.DataAccess + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Targets ------------------------------------------------------ + +XCSFILES= \ + Drivers.xcs + +.INCLUDE : target.mk + -- cgit