LibreOffice Module connectivity (master) 1
CDriver.cxx
Go to the documentation of this file.
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>
25#include <strings.hrc>
26
27using namespace connectivity::calc;
28using namespace connectivity::file;
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::beans;
31using namespace ::com::sun::star::sdbcx;
32using namespace ::com::sun::star::sdbc;
33using namespace ::com::sun::star::lang;
34
35
36// ServiceInfo
37
38OUString SAL_CALL ODriver::getImplementationName( )
39{
40 return "com.sun.star.comp.sdbc.calc.ODriver";
41}
42
43// service names from file::OFileDriver
44
45extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
47 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
48{
50 try {
51 ret = new ODriver(context);
52 } catch (...) {
53 }
54 if (ret)
55 ret->acquire();
56 return getXWeak(ret.get());
57}
58
59
60
61Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url,
62 const Sequence< PropertyValue >& info )
63{
64 ::osl::MutexGuard aGuard( m_aMutex );
65 if (ODriver_BASE::rBHelper.bDisposed)
66 throw DisposedException();
67
68 if ( ! acceptsURL(url) )
69 return nullptr;
70
72 pCon->construct(url,info);
73 m_xConnections.push_back(WeakReferenceHelper(*pCon));
74
75 return pCon;
76}
77
78sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
79{
80 return url.startsWith("sdbc:calc:");
81}
82
83Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ )
84{
85 if ( !acceptsURL(url) )
86 {
87 SharedResources aResources;
88 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
90 }
92}
93
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * connectivity_calc_ODriver(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: CDriver.cxx:46
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceString(TranslateId pResId) const
loads a string from the shared resource file
virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
virtual sal_Bool SAL_CALL acceptsURL(const OUString &url) override
Definition: CDriver.cxx:78
connectivity::OWeakRefArray m_xConnections
Definition: FDriver.hxx:40
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
OUString sMessage
unsigned char sal_Bool