Use correct object
[LibreOffice.git] / connectivity / source / drivers / dbase / DDriver.cxx
blob5191dc61f586dc487979e0115d605e814d5cc30c
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 <dbase/DDriver.hxx>
21 #include <dbase/DConnection.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <strings.hrc>
26 using namespace connectivity::dbase;
27 using namespace connectivity::file;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::beans;
30 using namespace ::com::sun::star::sdbcx;
31 using namespace ::com::sun::star::sdbc;
32 using namespace ::com::sun::star::lang;
35 // XServiceInfo
37 OUString SAL_CALL ODriver::getImplementationName( )
39 return u"com.sun.star.comp.sdbc.dbase.ODriver"_ustr;
43 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
44 connectivity_dbase_ODriver(
45 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
47 rtl::Reference<ODriver> ret;
48 try {
49 ret = new ODriver(context);
50 } catch (...) {
52 if (ret)
53 ret->acquire();
54 return getXWeak(ret.get());
58 Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const Sequence< PropertyValue >& info )
60 ::osl::MutexGuard aGuard( m_aMutex );
61 if (ODriver_BASE::rBHelper.bDisposed)
62 throw DisposedException();
64 if ( ! acceptsURL(url) )
65 return nullptr;
67 rtl::Reference<ODbaseConnection> pCon = new ODbaseConnection(this);
68 pCon->construct(url,info);
69 m_xConnections.push_back(WeakReferenceHelper(*pCon));
71 return pCon;
74 sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
76 return url.startsWith("sdbc:dbase:");
79 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ )
81 if ( acceptsURL(url) )
83 Sequence< OUString > aBoolean { u"0"_ustr, u"1"_ustr };
85 return
88 u"CharSet"_ustr
89 ,u"CharSet of the database."_ustr
90 ,false
91 ,OUString()
92 ,Sequence< OUString >()
95 u"ShowDeleted"_ustr
96 ,u"Display inactive records."_ustr
97 ,false
98 ,u"0"_ustr
99 ,aBoolean
102 u"EnableSQL92Check"_ustr
103 ,u"Use SQL92 naming constraints."_ustr
104 ,false
105 ,u"0"_ustr
106 ,aBoolean
111 SharedResources aResources;
112 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
113 ::dbtools::throwGenericSQLException(sMessage ,*this);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */