Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / calc / CDriver.cxx
blob937cdc542e6d1d8c46ab5d9a7249821e9a140383
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CDriver.cxx,v $
10 * $Revision: 1.9.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "calc/CDriver.hxx"
34 #include "calc/CConnection.hxx"
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include "connectivity/dbexception.hxx"
37 #include "resource/sharedresources.hxx"
38 #include "resource/calc_res.hrc"
40 using namespace connectivity::calc;
41 using namespace connectivity::file;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::beans;
44 using namespace ::com::sun::star::sdbcx;
45 using namespace ::com::sun::star::sdbc;
46 using namespace ::com::sun::star::lang;
49 //------------------------------------------------------------------------------
50 // static ServiceInfo
52 rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
54 return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.calc.ODriver");
57 ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
59 return getImplementationName_Static();
62 // service names from file::OFileDriver
64 //------------------------------------------------------------------
66 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
67 connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
68 ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
70 return *(new ODriver(_rxFactory));
73 Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url,
74 const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
76 ::osl::MutexGuard aGuard( m_aMutex );
77 if (ODriver_BASE::rBHelper.bDisposed)
78 throw DisposedException();
80 if ( ! acceptsURL(url) )
81 return NULL;
83 OCalcConnection* pCon = new OCalcConnection(this);
84 pCon->construct(url,info);
85 Reference< XConnection > xCon = pCon;
86 m_xConnections.push_back(WeakReferenceHelper(*pCon));
88 return xCon;
91 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
92 throw(SQLException, RuntimeException)
94 return url.compareTo(::rtl::OUString::createFromAscii("sdbc:calc:"),10) == 0;
97 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
99 if ( !acceptsURL(url) )
101 SharedResources aResources;
102 const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
103 ::dbtools::throwGenericSQLException(sMessage ,*this);
105 return Sequence< DriverPropertyInfo >();
107 // -----------------------------------------------------------------------------