Branch data 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 "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 : :
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;
34 : :
35 : :
36 : : //------------------------------------------------------------------------------
37 : : // static ServiceInfo
38 : :
39 : 0 : rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
40 : : {
41 : 0 : return rtl::OUString("com.sun.star.comp.sdbc.calc.ODriver");
42 : : }
43 : :
44 : 0 : ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
45 : : {
46 : 0 : return getImplementationName_Static();
47 : : }
48 : :
49 : : // service names from file::OFileDriver
50 : :
51 : : //------------------------------------------------------------------
52 : :
53 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
54 : 0 : connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
55 : : ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
56 : : {
57 : 0 : return *(new ODriver(_rxFactory));
58 : : }
59 : :
60 : 0 : Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url,
61 : : const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
62 : : {
63 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
64 : 0 : if (ODriver_BASE::rBHelper.bDisposed)
65 : 0 : throw DisposedException();
66 : :
67 : 0 : if ( ! acceptsURL(url) )
68 : 0 : return NULL;
69 : :
70 : 0 : OCalcConnection* pCon = new OCalcConnection(this);
71 : 0 : pCon->construct(url,info);
72 : 0 : Reference< XConnection > xCon = pCon;
73 : 0 : m_xConnections.push_back(WeakReferenceHelper(*pCon));
74 : :
75 : 0 : return xCon;
76 : : }
77 : :
78 : 0 : sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
79 : : throw(SQLException, RuntimeException)
80 : : {
81 : 0 : return url.compareTo(::rtl::OUString("sdbc:calc:"),10) == 0;
82 : : }
83 : :
84 : 0 : Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
85 : : {
86 : 0 : if ( !acceptsURL(url) )
87 : : {
88 : 0 : SharedResources aResources;
89 : 0 : const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
90 : 0 : ::dbtools::throwGenericSQLException(sMessage ,*this);
91 : : }
92 : 0 : return Sequence< DriverPropertyInfo >();
93 : : }
94 : : // -----------------------------------------------------------------------------
95 : :
96 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|