1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <comphelper/processfactory.hxx>
26 #include <strings.hrc>
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
;
39 OUString
ODriver::getImplementationName_Static( )
41 return OUString("com.sun.star.comp.sdbc.calc.ODriver");
44 OUString SAL_CALL
ODriver::getImplementationName( )
46 return getImplementationName_Static();
49 // service names from file::OFileDriver
52 css::uno::Reference
< css::uno::XInterface
>
53 connectivity::calc::ODriver_CreateInstance(const css::uno::Reference
<
54 css::lang::XMultiServiceFactory
>& _rxFactory
)
56 return *(new ODriver( comphelper::getComponentContext(_rxFactory
) ));
59 Reference
< XConnection
> SAL_CALL
ODriver::connect( const OUString
& url
,
60 const Sequence
< PropertyValue
>& info
)
62 ::osl::MutexGuard
aGuard( m_aMutex
);
63 if (ODriver_BASE::rBHelper
.bDisposed
)
64 throw DisposedException();
66 if ( ! acceptsURL(url
) )
69 OCalcConnection
* pCon
= new OCalcConnection(this);
70 pCon
->construct(url
,info
);
71 Reference
< XConnection
> xCon
= pCon
;
72 m_xConnections
.push_back(WeakReferenceHelper(*pCon
));
77 sal_Bool SAL_CALL
ODriver::acceptsURL( const OUString
& url
)
79 return url
.startsWith("sdbc:calc:");
82 Sequence
< DriverPropertyInfo
> SAL_CALL
ODriver::getPropertyInfo( const OUString
& url
, const Sequence
< PropertyValue
>& /*info*/ )
84 if ( !acceptsURL(url
) )
86 SharedResources aResources
;
87 const OUString sMessage
= aResources
.getResourceString(STR_URI_SYNTAX_ERROR
);
88 ::dbtools::throwGenericSQLException(sMessage
,*this);
90 return Sequence
< DriverPropertyInfo
>();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */