Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / dbase / DDriver.cxx
blob3a2139bdb9e1797fa94c05a72aca19df355c7d7e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DDriver.cxx,v $
10 * $Revision: 1.11.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "dbase/DDriver.hxx"
34 #include "dbase/DConnection.hxx"
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include "connectivity/dbexception.hxx"
37 #include "resource/dbase_res.hrc"
39 using namespace connectivity::dbase;
40 using namespace connectivity::file;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::beans;
43 using namespace ::com::sun::star::sdbcx;
44 using namespace ::com::sun::star::sdbc;
45 using namespace ::com::sun::star::lang;
48 // static ServiceInfo
49 //------------------------------------------------------------------------------
50 rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
52 return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.dbase.ODriver");
55 //------------------------------------------------------------------
56 ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
58 return getImplementationName_Static();
61 //------------------------------------------------------------------
62 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::dbase::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
64 return *(new ODriver(_rxFactory));
66 // --------------------------------------------------------------------------------
67 Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
69 ::osl::MutexGuard aGuard( m_aMutex );
70 if (ODriver_BASE::rBHelper.bDisposed)
71 throw DisposedException();
73 if ( ! acceptsURL(url) )
74 return NULL;
76 ODbaseConnection* pCon = new ODbaseConnection(this);
77 pCon->construct(url,info);
78 Reference< XConnection > xCon = pCon;
79 m_xConnections.push_back(WeakReferenceHelper(*pCon));
81 return xCon;
83 // --------------------------------------------------------------------------------
84 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
86 return !url.compareTo(::rtl::OUString::createFromAscii("sdbc:dbase:"),11);
88 // -----------------------------------------------------------------------------
89 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
91 if ( acceptsURL(url) )
93 ::std::vector< DriverPropertyInfo > aDriverInfo;
95 Sequence< ::rtl::OUString > aBoolean(2);
96 aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
97 aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
99 aDriverInfo.push_back(DriverPropertyInfo(
100 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
101 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
102 ,sal_False
103 ,::rtl::OUString()
104 ,Sequence< ::rtl::OUString >())
106 aDriverInfo.push_back(DriverPropertyInfo(
107 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))
108 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Display inactive records."))
109 ,sal_False
110 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
111 ,aBoolean)
113 aDriverInfo.push_back(DriverPropertyInfo(
114 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EnableSQL92Check"))
115 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Use SQL92 naming constraints."))
116 ,sal_False
117 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
118 ,aBoolean)
120 return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
123 SharedResources aResources;
124 const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
125 ::dbtools::throwGenericSQLException(sMessage ,*this);
126 return Sequence< DriverPropertyInfo >();
128 // -----------------------------------------------------------------------------