LibreOffice Module connectivity (master) 1
DDriver.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 <dbase/DDriver.hxx>
21#include <dbase/DConnection.hxx>
22#include <com/sun/star/lang/DisposedException.hpp>
24#include <strings.hrc>
25
26using namespace connectivity::dbase;
27using namespace connectivity::file;
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::beans;
30using namespace ::com::sun::star::sdbcx;
31using namespace ::com::sun::star::sdbc;
32using namespace ::com::sun::star::lang;
33
34
35// XServiceInfo
36
37OUString SAL_CALL ODriver::getImplementationName( )
38{
39 return "com.sun.star.comp.sdbc.dbase.ODriver";
40}
41
42
43extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
45 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
46{
48 try {
49 ret = new ODriver(context);
50 } catch (...) {
51 }
52 if (ret)
53 ret->acquire();
54 return getXWeak(ret.get());
55}
56
57
58Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const Sequence< PropertyValue >& info )
59{
60 ::osl::MutexGuard aGuard( m_aMutex );
61 if (ODriver_BASE::rBHelper.bDisposed)
62 throw DisposedException();
63
64 if ( ! acceptsURL(url) )
65 return nullptr;
66
68 pCon->construct(url,info);
69 m_xConnections.push_back(WeakReferenceHelper(*pCon));
70
71 return pCon;
72}
73
74sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
75{
76 return url.startsWith("sdbc:dbase:");
77}
78
79Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ )
80{
81 if ( acceptsURL(url) )
82 {
83 Sequence< OUString > aBoolean { "0", "1" };
84
85 return
86 {
87 {
88 "CharSet"
89 ,"CharSet of the database."
90 ,false
91 ,OUString()
93 },
94 {
95 "ShowDeleted"
96 ,"Display inactive records."
97 ,false
98 ,"0"
99 ,aBoolean
100 },
101 {
102 "EnableSQL92Check"
103 ,"Use SQL92 naming constraints."
104 ,false
105 ,"0"
106 ,aBoolean
107 }
108 };
109 }
110
111 SharedResources aResources;
112 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
115}
116
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * connectivity_dbase_ODriver(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: DDriver.cxx:44
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
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: DDriver.cxx:74
connectivity::OWeakRefArray m_xConnections
Definition: FDriver.hxx:40
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