1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include <cppuhelper/supportsservice.hxx>
38 #include <cppuhelper/weak.hxx>
39 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
41 #include "pq_driver.hxx"
43 using osl::MutexGuard
;
45 using com::sun::star::lang::XSingleComponentFactory
;
46 using com::sun::star::lang::XServiceInfo
;
47 using com::sun::star::lang::XComponent
;
49 using com::sun::star::uno::Sequence
;
50 using com::sun::star::uno::Reference
;
51 using com::sun::star::uno::XInterface
;
52 using com::sun::star::uno::UNO_QUERY
;
53 using com::sun::star::uno::XComponentContext
;
54 using com::sun::star::uno::Any
;
56 using com::sun::star::beans::PropertyValue
;
58 using com::sun::star::sdbc::XConnection
;
59 using com::sun::star::sdbc::DriverPropertyInfo
;
61 using com::sun::star::sdbcx::XTablesSupplier
;
64 namespace pq_sdbc_driver
67 Reference
< XConnection
> Driver::connect(
68 const OUString
& url
,const Sequence
< PropertyValue
>& info
)
70 if( ! acceptsURL( url
) ) // XDriver spec tells me to do so ...
71 return Reference
< XConnection
> ();
73 Sequence
< Any
> seq ( 2 );
76 return Reference
< XConnection
> (
77 m_smgr
->createInstanceWithArgumentsAndContext(
78 "org.openoffice.comp.connectivity.pq.Connection.noext",
83 sal_Bool
Driver::acceptsURL( const OUString
& url
)
85 return url
.startsWith( "sdbc:postgresql:" );
88 Sequence
< DriverPropertyInfo
> Driver::getPropertyInfo(
89 const OUString
&,const Sequence
< PropertyValue
>& )
91 return Sequence
< DriverPropertyInfo
> ();
94 sal_Int32
Driver::getMajorVersion( )
100 sal_Int32
Driver::getMinorVersion( )
102 return PQ_SDBC_MINOR
;
106 OUString SAL_CALL
Driver::getImplementationName()
108 return "org.openoffice.comp.connectivity.pq.Driver.noext";
111 sal_Bool
Driver::supportsService(const OUString
& ServiceName
)
113 return cppu::supportsService(this, ServiceName
);
116 Sequence
< OUString
> Driver::getSupportedServiceNames()
118 return { "com.sun.star.sdbc.Driver" };
122 void Driver::disposing()
128 Reference
< XTablesSupplier
> Driver::getDataDefinitionByConnection(
129 const Reference
< XConnection
>& connection
)
131 return Reference
< XTablesSupplier
>( connection
, UNO_QUERY
);
134 Reference
< XTablesSupplier
> Driver::getDataDefinitionByURL(
135 const OUString
& url
, const Sequence
< PropertyValue
>& info
)
137 return Reference
< XTablesSupplier
> ( connect( url
, info
), UNO_QUERY
);
142 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
143 connectivity_pq_sdbc_driver_get_implementation(
144 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
146 return cppu::acquire(static_cast<cppu::OWeakObject
*>(new pq_sdbc_driver::Driver(context
)));
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */