LibreOffice Module connectivity (master) 1
WDriver.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 <writer/WDriver.hxx>
22#include <com/sun/star/lang/DisposedException.hpp>
25#include <strings.hrc>
26
27using namespace connectivity::file;
28using namespace ::com::sun::star;
29
31{
33{
34 return "com.sun.star.comp.sdbc.writer.ODriver";
35}
36
37extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
38connectivity_writer_ODriver(css::uno::XComponentContext* context,
39 css::uno::Sequence<css::uno::Any> const& /*rArguments*/)
40{
41 try
42 {
43 return acquire(new ODriver(context));
44 }
45 catch (...)
46 {
47 }
48 return nullptr;
49}
50
51uno::Reference<sdbc::XConnection>
52 SAL_CALL ODriver::connect(const OUString& url, const uno::Sequence<beans::PropertyValue>& info)
53{
54 ::osl::MutexGuard aGuard(m_aMutex);
55 if (ODriver_BASE::rBHelper.bDisposed)
56 throw lang::DisposedException();
57
58 if (!acceptsURL(url))
59 return nullptr;
60
61 rtl::Reference<OWriterConnection> pCon = new OWriterConnection(this);
62 pCon->construct(url, info);
63 m_xConnections.push_back(uno::WeakReferenceHelper(*pCon));
64
65 return pCon;
66}
67
68sal_Bool SAL_CALL ODriver::acceptsURL(const OUString& url)
69{
70 return url.startsWith("sdbc:writer:");
71}
72
73uno::Sequence<sdbc::DriverPropertyInfo> SAL_CALL
74ODriver::getPropertyInfo(const OUString& url, const uno::Sequence<beans::PropertyValue>& /*info*/)
75{
76 if (!acceptsURL(url))
77 {
78 SharedResources aResources;
79 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
81 }
82 return {};
83}
84
85} // namespace
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
connectivity::OWeakRefArray m_xConnections
Definition: FDriver.hxx:40
OUString SAL_CALL getImplementationName() override
Definition: WDriver.cxx:32
sal_Bool SAL_CALL acceptsURL(const OUString &url) override
Definition: WDriver.cxx:68
css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * connectivity_writer_ODriver(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: WDriver.cxx:38
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