Line data Source code
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>
23 : #include <connectivity/dbexception.hxx>
24 : #include "resource/dbase_res.hrc"
25 : #include <comphelper/processfactory.hxx>
26 :
27 : using namespace connectivity::dbase;
28 : using namespace connectivity::file;
29 : using namespace ::com::sun::star::uno;
30 : using namespace ::com::sun::star::beans;
31 : using namespace ::com::sun::star::sdbcx;
32 : using namespace ::com::sun::star::sdbc;
33 : using namespace ::com::sun::star::lang;
34 :
35 :
36 : // static ServiceInfo
37 :
38 10 : OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
39 : {
40 10 : return OUString("com.sun.star.comp.sdbc.dbase.ODriver");
41 : }
42 :
43 :
44 0 : OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException, std::exception)
45 : {
46 0 : return getImplementationName_Static();
47 : }
48 :
49 :
50 10 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::dbase::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
51 : {
52 10 : return *(new ODriver( comphelper::getComponentContext(_rxFactory) ));
53 : }
54 :
55 58 : Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException, std::exception)
56 : {
57 58 : ::osl::MutexGuard aGuard( m_aMutex );
58 58 : if (ODriver_BASE::rBHelper.bDisposed)
59 0 : throw DisposedException();
60 :
61 58 : if ( ! acceptsURL(url) )
62 0 : return NULL;
63 :
64 58 : ODbaseConnection* pCon = new ODbaseConnection(this);
65 58 : pCon->construct(url,info);
66 116 : Reference< XConnection > xCon = pCon;
67 58 : m_xConnections.push_back(WeakReferenceHelper(*pCon));
68 :
69 116 : return xCon;
70 : }
71 :
72 348 : sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url ) throw(SQLException, RuntimeException, std::exception)
73 : {
74 348 : return url.startsWith("sdbc:dbase:");
75 : }
76 :
77 58 : Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException, std::exception)
78 : {
79 58 : if ( acceptsURL(url) )
80 : {
81 58 : ::std::vector< DriverPropertyInfo > aDriverInfo;
82 :
83 116 : Sequence< OUString > aBoolean(2);
84 58 : aBoolean[0] = "0";
85 58 : aBoolean[1] = "1";
86 :
87 : aDriverInfo.push_back(DriverPropertyInfo(
88 : OUString("CharSet")
89 : ,OUString("CharSet of the database.")
90 : ,sal_False
91 : ,OUString()
92 : ,Sequence< OUString >())
93 58 : );
94 : aDriverInfo.push_back(DriverPropertyInfo(
95 : OUString("ShowDeleted")
96 : ,OUString("Display inactive records.")
97 : ,sal_False
98 : ,OUString("0")
99 : ,aBoolean)
100 58 : );
101 : aDriverInfo.push_back(DriverPropertyInfo(
102 : OUString("EnableSQL92Check")
103 : ,OUString("Use SQL92 naming constraints.")
104 : ,sal_False
105 : ,OUString("0")
106 : ,aBoolean)
107 58 : );
108 116 : return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
109 : }
110 :
111 0 : SharedResources aResources;
112 0 : const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
113 0 : ::dbtools::throwGenericSQLException(sMessage ,*this);
114 0 : return Sequence< DriverPropertyInfo >();
115 : }
116 :
117 :
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|