Use correct object
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_driver.cxx
bloba1025017d8c7a2f1c5ea1f06e962bf5b6b7436a0
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,
18 * MA 02111-1307 USA
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 com::sun::star::uno::Sequence;
44 using com::sun::star::uno::Reference;
45 using com::sun::star::uno::XInterface;
46 using com::sun::star::uno::UNO_QUERY;
47 using com::sun::star::uno::XComponentContext;
48 using com::sun::star::uno::Any;
50 using com::sun::star::beans::PropertyValue;
52 using com::sun::star::sdbc::XConnection;
53 using com::sun::star::sdbc::DriverPropertyInfo;
55 using com::sun::star::sdbcx::XTablesSupplier;
58 namespace pq_sdbc_driver
61 Reference< XConnection > Driver::connect(
62 const OUString& url,const Sequence< PropertyValue >& info )
64 if( ! acceptsURL( url ) ) // XDriver spec tells me to do so ...
65 return Reference< XConnection > ();
67 Sequence< Any > seq{ Any(url), Any(info) };
68 return Reference< XConnection> (
69 m_smgr->createInstanceWithArgumentsAndContext(
70 u"org.openoffice.comp.connectivity.pq.Connection.noext"_ustr,
71 seq, m_ctx ),
72 UNO_QUERY );
75 sal_Bool Driver::acceptsURL( const OUString& url )
77 return url.startsWith( "sdbc:postgresql:" );
80 Sequence< DriverPropertyInfo > Driver::getPropertyInfo(
81 const OUString&,const Sequence< PropertyValue >& )
83 return Sequence< DriverPropertyInfo > ();
86 sal_Int32 Driver::getMajorVersion( )
88 return PQ_SDBC_MAJOR;
92 sal_Int32 Driver::getMinorVersion( )
94 return PQ_SDBC_MINOR;
97 // XServiceInfo
98 OUString SAL_CALL Driver::getImplementationName()
100 return u"org.openoffice.comp.connectivity.pq.Driver.noext"_ustr;
103 sal_Bool Driver::supportsService(const OUString& ServiceName)
105 return cppu::supportsService(this, ServiceName);
108 Sequence< OUString > Driver::getSupportedServiceNames()
110 return { u"com.sun.star.sdbc.Driver"_ustr };
113 // XComponent
114 void Driver::disposing()
120 Reference< XTablesSupplier > Driver::getDataDefinitionByConnection(
121 const Reference< XConnection >& connection )
123 return Reference< XTablesSupplier >( connection , UNO_QUERY );
126 Reference< XTablesSupplier > Driver::getDataDefinitionByURL(
127 const OUString& url, const Sequence< PropertyValue >& info )
129 return Reference< XTablesSupplier > ( connect( url, info ), UNO_QUERY );
134 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
135 connectivity_pq_sdbc_driver_get_implementation(
136 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
138 return cppu::acquire(new pq_sdbc_driver::Driver(context));
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */