1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
40 OUString SAL_CALL
ODriver::getImplementationName( )
42 return u
"com.sun.star.comp.sdbc.flat.ODriver"_ustr
;
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
;
52 ret
= new ODriver(context
);
57 return getXWeak(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
) )
69 rtl::Reference
<OFlatConnection
> pCon
= new OFlatConnection(this);
70 pCon
->construct(url
,info
);
71 m_xConnections
.emplace_back(*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
{ u
"0"_ustr
, u
"1"_ustr
};
87 std::vector
< DriverPropertyInfo
> aDriverInfo
90 u
"FieldDelimiter"_ustr
91 ,u
"Field separator."_ustr
98 ,u
"Text contains headers."_ustr
104 u
"StringDelimiter"_ustr
105 ,u
"Text separator."_ustr
111 u
"DecimalDelimiter"_ustr
112 ,u
"Decimal separator."_ustr
118 u
"ThousandDelimiter"_ustr
119 ,u
"Thousands separator."_ustr
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);
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */