Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / dbase / DDriver.cxx
blob86d622ae39b48df5c80e0ff6f422e9a37c8eef76
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "dbase/DDriver.hxx"
30 #include "dbase/DConnection.hxx"
31 #include <com/sun/star/lang/DisposedException.hpp>
32 #include "connectivity/dbexception.hxx"
33 #include "resource/dbase_res.hrc"
35 using namespace connectivity::dbase;
36 using namespace connectivity::file;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::sdbcx;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::lang;
44 // static ServiceInfo
45 //------------------------------------------------------------------------------
46 rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
48 return rtl::OUString("com.sun.star.comp.sdbc.dbase.ODriver");
51 //------------------------------------------------------------------
52 ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
54 return getImplementationName_Static();
57 //------------------------------------------------------------------
58 ::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 )
60 return *(new ODriver(_rxFactory));
62 // --------------------------------------------------------------------------------
63 Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
65 ::osl::MutexGuard aGuard( m_aMutex );
66 if (ODriver_BASE::rBHelper.bDisposed)
67 throw DisposedException();
69 if ( ! acceptsURL(url) )
70 return NULL;
72 ODbaseConnection* pCon = new ODbaseConnection(this);
73 pCon->construct(url,info);
74 Reference< XConnection > xCon = pCon;
75 m_xConnections.push_back(WeakReferenceHelper(*pCon));
77 return xCon;
79 // --------------------------------------------------------------------------------
80 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
82 return !url.compareTo(::rtl::OUString("sdbc:dbase:"),11);
84 // -----------------------------------------------------------------------------
85 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
87 if ( acceptsURL(url) )
89 ::std::vector< DriverPropertyInfo > aDriverInfo;
91 Sequence< ::rtl::OUString > aBoolean(2);
92 aBoolean[0] = ::rtl::OUString("0");
93 aBoolean[1] = ::rtl::OUString("1");
95 aDriverInfo.push_back(DriverPropertyInfo(
96 ::rtl::OUString("CharSet")
97 ,::rtl::OUString("CharSet of the database.")
98 ,sal_False
99 ,::rtl::OUString()
100 ,Sequence< ::rtl::OUString >())
102 aDriverInfo.push_back(DriverPropertyInfo(
103 ::rtl::OUString("ShowDeleted")
104 ,::rtl::OUString("Display inactive records.")
105 ,sal_False
106 ,::rtl::OUString("0")
107 ,aBoolean)
109 aDriverInfo.push_back(DriverPropertyInfo(
110 ::rtl::OUString("EnableSQL92Check")
111 ,::rtl::OUString("Use SQL92 naming constraints.")
112 ,sal_False
113 ,::rtl::OUString("0")
114 ,aBoolean)
116 return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
119 SharedResources aResources;
120 const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
121 ::dbtools::throwGenericSQLException(sMessage ,*this);
122 return Sequence< DriverPropertyInfo >();
124 // -----------------------------------------------------------------------------
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */