Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / flat / EDriver.cxx
blobe61463f56e7ea9b7ec16fb9830575dc720411cfb
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 "flat/EDriver.hxx"
30 #include "flat/EConnection.hxx"
31 #include <com/sun/star/lang/DisposedException.hpp>
32 #include "connectivity/dbexception.hxx"
33 #include <comphelper/sequence.hxx>
34 #include "resource/common_res.hrc"
35 #include "resource/sharedresources.hxx"
38 using namespace connectivity::flat;
39 using namespace connectivity::file;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::beans;
42 using namespace ::com::sun::star::sdbcx;
43 using namespace ::com::sun::star::sdbc;
44 using namespace ::com::sun::star::lang;
47 // static ServiceInfo
48 //------------------------------------------------------------------------------
49 rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
51 return rtl::OUString("com.sun.star.comp.sdbc.flat.ODriver");
54 //------------------------------------------------------------------
55 ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
57 return getImplementationName_Static();
60 //------------------------------------------------------------------
61 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::flat::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
63 return *(new ODriver(_rxFactory));
65 // --------------------------------------------------------------------------------
66 Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
68 ::osl::MutexGuard aGuard( m_aMutex );
69 if (ODriver_BASE::rBHelper.bDisposed)
70 throw DisposedException();
72 if ( ! acceptsURL(url) )
73 return NULL;
75 OFlatConnection* pCon = new OFlatConnection(this);
76 pCon->construct(url,info);
77 Reference< XConnection > xCon = pCon;
78 m_xConnections.push_back(WeakReferenceHelper(*pCon));
80 return xCon;
82 // --------------------------------------------------------------------------------
83 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
84 throw(SQLException, RuntimeException)
86 return url.compareTo(::rtl::OUString("sdbc:flat:"),10) == 0;
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("0");
97 aBoolean[1] = ::rtl::OUString("1");
99 aDriverInfo.push_back(DriverPropertyInfo(
100 ::rtl::OUString("FieldDelimiter")
101 ,::rtl::OUString("Field separator.")
102 ,sal_False
103 ,::rtl::OUString()
104 ,Sequence< ::rtl::OUString >())
106 aDriverInfo.push_back(DriverPropertyInfo(
107 ::rtl::OUString("HeaderLine")
108 ,::rtl::OUString("Text contains headers.")
109 ,sal_False
110 ,::rtl::OUString("0")
111 ,aBoolean)
113 aDriverInfo.push_back(DriverPropertyInfo(
114 ::rtl::OUString("StringDelimiter")
115 ,::rtl::OUString("Text separator.")
116 ,sal_False
117 ,::rtl::OUString("0")
118 ,aBoolean)
120 aDriverInfo.push_back(DriverPropertyInfo(
121 ::rtl::OUString("DecimalDelimiter")
122 ,::rtl::OUString("Decimal separator.")
123 ,sal_False
124 ,::rtl::OUString("0")
125 ,aBoolean)
127 aDriverInfo.push_back(DriverPropertyInfo(
128 ::rtl::OUString("ThousandDelimiter")
129 ,::rtl::OUString("Thousands separator.")
130 ,sal_False
131 ,::rtl::OUString("0")
132 ,aBoolean)
134 return ::comphelper::concatSequences(OFileDriver::getPropertyInfo(url,info ),
135 Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()));
137 ::connectivity::SharedResources aResources;
138 const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
139 ::dbtools::throwGenericSQLException(sMessage ,*this);
140 return Sequence< DriverPropertyInfo >();
142 // -----------------------------------------------------------------------------
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */