LibreOffice Module connectivity (master) 1
EDriver.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <flat/EDriver.hxx>
21#include <flat/EConnection.hxx>
22#include <com/sun/star/lang/DisposedException.hpp>
25#include <strings.hrc>
27
28
29using namespace connectivity::flat;
30using namespace connectivity::file;
31using namespace css::uno;
32using namespace css::beans;
33using namespace css::sdbcx;
34using namespace css::sdbc;
35using namespace css::lang;
36
37
38// XServiceInfo
39
40OUString SAL_CALL ODriver::getImplementationName( )
41{
42 return "com.sun.star.comp.sdbc.flat.ODriver";
43}
44
45
46extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
48 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
49{
51 try {
52 ret = new ODriver(context);
53 } catch (...) {
54 }
55 if (ret)
56 ret->acquire();
57 return getXWeak(ret.get());
58}
59
60Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const Sequence< PropertyValue >& info )
61{
62 ::osl::MutexGuard aGuard( m_aMutex );
63 if (ODriver_BASE::rBHelper.bDisposed)
64 throw DisposedException();
65
66 if ( ! acceptsURL(url) )
67 return nullptr;
68
70 pCon->construct(url,info);
71 m_xConnections.push_back(WeakReferenceHelper(*pCon));
72
73 return pCon;
74}
75
76sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
77{
78 return url.startsWith("sdbc:flat:");
79}
80
82{
83 if ( acceptsURL(url) )
84 {
85 Sequence< OUString > aBoolean { "0", "1" };
86
87 std::vector< DriverPropertyInfo > aDriverInfo
88 {
89 {
90 "FieldDelimiter"
91 ,"Field separator."
92 ,false
93 ,{}
94 ,{}
95 },
96 {
97 "HeaderLine"
98 ,"Text contains headers."
99 ,false
100 ,"0"
101 ,aBoolean
102 },
103 {
104 "StringDelimiter"
105 ,"Text separator."
106 ,false
107 ,"0"
108 ,aBoolean
109 },
110 {
111 "DecimalDelimiter"
112 ,"Decimal separator."
113 ,false
114 ,"0"
115 ,aBoolean
116 },
117 {
118 "ThousandDelimiter"
119 ,"Thousands separator."
120 ,false
121 ,"0"
122 ,aBoolean
123 }
124 };
125 return ::comphelper::concatSequences(OFileDriver::getPropertyInfo(url,info ),
126 Sequence< DriverPropertyInfo >(aDriverInfo.data(),aDriverInfo.size()));
127 }
129 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
132}
133
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * connectivity_flat_ODriver(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: EDriver.cxx:47
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceString(TranslateId pResId) const
loads a string from the shared resource file
connectivity::OWeakRefArray m_xConnections
Definition: FDriver.hxx:40
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
virtual sal_Bool SAL_CALL acceptsURL(const OUString &url) override
Definition: EDriver.cxx:76
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
OUString sMessage
unsigned char sal_Bool