Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / calc / CDriver.cxx
blob6a8e91243265f264a35d52a72fa36fa8d5c830c0
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 "resource/calc_res.hrc"
26 #include "comphelper/processfactory.hxx"
28 using namespace connectivity::calc;
29 using namespace connectivity::file;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::sdbcx;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::lang;
38 // static ServiceInfo
40 OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
42 return OUString("com.sun.star.comp.sdbc.calc.ODriver");
45 OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException, std::exception)
47 return getImplementationName_Static();
50 // service names from file::OFileDriver
54 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
55 connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
56 ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
58 return *(new ODriver( comphelper::getComponentContext(_rxFactory) ));
61 Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url,
62 const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException, std::exception)
64 ::osl::MutexGuard aGuard( m_aMutex );
65 if (ODriver_BASE::rBHelper.bDisposed)
66 throw DisposedException();
68 if ( ! acceptsURL(url) )
69 return NULL;
71 OCalcConnection* pCon = new OCalcConnection(this);
72 pCon->construct(url,info);
73 Reference< XConnection > xCon = pCon;
74 m_xConnections.push_back(WeakReferenceHelper(*pCon));
76 return xCon;
79 sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
80 throw(SQLException, RuntimeException, std::exception)
82 return url.startsWith("sdbc:calc:");
85 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException, std::exception)
87 if ( !acceptsURL(url) )
89 SharedResources aResources;
90 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
91 ::dbtools::throwGenericSQLException(sMessage ,*this);
93 return Sequence< DriverPropertyInfo >();
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */