Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / connectivity / source / drivers / writer / WDriver.cxx
blob21325d73f6b610d99e2e6fa6360f3346310c08f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 try
43 return acquire(new ODriver(context));
45 catch (...)
48 return nullptr;
51 uno::Reference<sdbc::XConnection>
52 SAL_CALL ODriver::connect(const OUString& url, const uno::Sequence<beans::PropertyValue>& info)
54 ::osl::MutexGuard aGuard(m_aMutex);
55 if (ODriver_BASE::rBHelper.bDisposed)
56 throw lang::DisposedException();
58 if (!acceptsURL(url))
59 return nullptr;
61 rtl::Reference<OWriterConnection> pCon = new OWriterConnection(this);
62 pCon->construct(url, info);
63 m_xConnections.push_back(uno::WeakReferenceHelper(*pCon));
65 return pCon;
68 sal_Bool SAL_CALL ODriver::acceptsURL(const OUString& url)
70 return url.startsWith("sdbc:writer:");
73 uno::Sequence<sdbc::DriverPropertyInfo> SAL_CALL
74 ODriver::getPropertyInfo(const OUString& url, const uno::Sequence<beans::PropertyValue>& /*info*/)
76 if (!acceptsURL(url))
78 SharedResources aResources;
79 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
80 ::dbtools::throwGenericSQLException(sMessage, *this);
82 return {};
85 } // namespace
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */