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 <writer/WDriver.hxx>
21 #include <writer/WConnection.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <resource/sharedresources.hxx>
25 #include <strings.hrc>
27 using namespace connectivity::file
;
28 using namespace ::com::sun::star
;
30 namespace connectivity::writer
32 OUString SAL_CALL
ODriver::getImplementationName()
34 return "com.sun.star.comp.sdbc.writer.ODriver";
37 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
38 connectivity_writer_ODriver(css::uno::XComponentContext
* context
,
39 css::uno::Sequence
<css::uno::Any
> const& /*rArguments*/)
41 rtl::Reference
<ODriver
> ret
;
44 ret
= new ODriver(context
);
51 return static_cast<cppu::OWeakObject
*>(ret
.get());
54 uno::Reference
<sdbc::XConnection
>
55 SAL_CALL
ODriver::connect(const OUString
& url
, const uno::Sequence
<beans::PropertyValue
>& info
)
57 ::osl::MutexGuard
aGuard(m_aMutex
);
58 if (ODriver_BASE::rBHelper
.bDisposed
)
59 throw lang::DisposedException();
64 auto pCon
= new OWriterConnection(this);
65 pCon
->construct(url
, info
);
66 uno::Reference
<sdbc::XConnection
> xCon
= pCon
;
67 m_xConnections
.push_back(uno::WeakReferenceHelper(*pCon
));
72 sal_Bool SAL_CALL
ODriver::acceptsURL(const OUString
& url
)
74 return url
.startsWith("sdbc:writer:");
77 uno::Sequence
<sdbc::DriverPropertyInfo
> SAL_CALL
78 ODriver::getPropertyInfo(const OUString
& url
, const uno::Sequence
<beans::PropertyValue
>& /*info*/)
82 SharedResources aResources
;
83 const OUString sMessage
= aResources
.getResourceString(STR_URI_SYNTAX_ERROR
);
84 ::dbtools::throwGenericSQLException(sMessage
, *this);
86 return uno::Sequence
<sdbc::DriverPropertyInfo
>();
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */