bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / flat / EDriver.cxx
blob29492895510ec29d00cad15b977a2ce5a4eeefe1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <flat/EDriver.hxx>
21 #include <flat/EConnection.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <comphelper/sequence.hxx>
25 #include <strings.hrc>
26 #include <resource/sharedresources.hxx>
29 using namespace connectivity::flat;
30 using namespace connectivity::file;
31 using namespace css::uno;
32 using namespace css::beans;
33 using namespace css::sdbcx;
34 using namespace css::sdbc;
35 using namespace css::lang;
38 // XServiceInfo
40 OUString SAL_CALL ODriver::getImplementationName( )
42 return "com.sun.star.comp.sdbc.flat.ODriver";
46 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
47 connectivity_flat_ODriver(
48 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
50 rtl::Reference<ODriver> ret;
51 try {
52 ret = new ODriver(context);
53 } catch (...) {
55 if (ret)
56 ret->acquire();
57 return static_cast<cppu::OWeakObject*>(ret.get());
60 Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const Sequence< PropertyValue >& info )
62 ::osl::MutexGuard aGuard( m_aMutex );
63 if (ODriver_BASE::rBHelper.bDisposed)
64 throw DisposedException();
66 if ( ! acceptsURL(url) )
67 return nullptr;
69 rtl::Reference<OFlatConnection> pCon = new OFlatConnection(this);
70 pCon->construct(url,info);
71 m_xConnections.push_back(WeakReferenceHelper(*pCon));
73 return pCon;
76 sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
78 return url.startsWith("sdbc:flat:");
81 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& info )
83 if ( acceptsURL(url) )
85 Sequence< OUString > aBoolean { "0", "1" };
87 std::vector< DriverPropertyInfo > aDriverInfo
90 "FieldDelimiter"
91 ,"Field separator."
92 ,false
93 ,{}
94 ,{}
97 "HeaderLine"
98 ,"Text contains headers."
99 ,false
100 ,"0"
101 ,aBoolean
104 "StringDelimiter"
105 ,"Text separator."
106 ,false
107 ,"0"
108 ,aBoolean
111 "DecimalDelimiter"
112 ,"Decimal separator."
113 ,false
114 ,"0"
115 ,aBoolean
118 "ThousandDelimiter"
119 ,"Thousands separator."
120 ,false
121 ,"0"
122 ,aBoolean
125 return ::comphelper::concatSequences(OFileDriver::getPropertyInfo(url,info ),
126 Sequence< DriverPropertyInfo >(aDriverInfo.data(),aDriverInfo.size()));
128 ::connectivity::SharedResources aResources;
129 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
130 ::dbtools::throwGenericSQLException(sMessage ,*this);
131 return Sequence< DriverPropertyInfo >();
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */