Use correct object
[LibreOffice.git] / connectivity / source / drivers / calc / CDriver.cxx
blob1bffa74db42434ee45916a61ea4d1d3bd1f1ff77
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 <calc/CDriver.hxx>
21 #include <calc/CConnection.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <resource/sharedresources.hxx>
25 #include <strings.hrc>
27 using namespace connectivity::calc;
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;
36 // ServiceInfo
38 OUString SAL_CALL ODriver::getImplementationName( )
40 return u"com.sun.star.comp.sdbc.calc.ODriver"_ustr;
43 // service names from file::OFileDriver
45 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
46 connectivity_calc_ODriver(
47 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
49 rtl::Reference<ODriver> ret;
50 try {
51 ret = new ODriver(context);
52 } catch (...) {
54 if (ret)
55 ret->acquire();
56 return getXWeak(ret.get());
61 Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url,
62 const Sequence< PropertyValue >& info )
64 ::osl::MutexGuard aGuard( m_aMutex );
65 if (ODriver_BASE::rBHelper.bDisposed)
66 throw DisposedException();
68 if ( ! acceptsURL(url) )
69 return nullptr;
71 rtl::Reference<OCalcConnection> pCon = new OCalcConnection(this);
72 pCon->construct(url,info);
73 m_xConnections.push_back(WeakReferenceHelper(*pCon));
75 return pCon;
78 sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
80 return url.startsWith("sdbc:calc:");
83 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ )
85 if ( !acceptsURL(url) )
87 SharedResources aResources;
88 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
89 ::dbtools::throwGenericSQLException(sMessage ,*this);
91 return Sequence< DriverPropertyInfo >();
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */