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 "resource/common_res.hrc"
26 #include <comphelper/processfactory.hxx>
28 using namespace connectivity::file
;
29 using namespace ::com::sun::star
;
31 namespace connectivity
36 OUString
ODriver::getImplementationName_Static() throw(uno::RuntimeException
)
38 return OUString("com.sun.star.comp.sdbc.writer.ODriver");
41 OUString SAL_CALL
ODriver::getImplementationName() throw(uno::RuntimeException
, std::exception
)
43 return getImplementationName_Static();
46 uno::Reference
< css::uno::XInterface
> SAL_CALL
47 ODriver_CreateInstance(const uno::Reference
<
48 lang::XMultiServiceFactory
>& _rxFactory
) throw( css::uno::Exception
)
50 return *(new ODriver(comphelper::getComponentContext(_rxFactory
)));
53 uno::Reference
< sdbc::XConnection
> SAL_CALL
ODriver::connect(const OUString
& url
,
54 const uno::Sequence
< beans::PropertyValue
>& info
) throw(sdbc::SQLException
, uno::RuntimeException
, std::exception
)
56 ::osl::MutexGuard
aGuard(m_aMutex
);
57 if (ODriver_BASE::rBHelper
.bDisposed
)
58 throw lang::DisposedException();
60 if (! acceptsURL(url
))
63 OWriterConnection
* pCon
= new OWriterConnection(this);
64 pCon
->construct(url
, info
);
65 uno::Reference
< sdbc::XConnection
> xCon
= pCon
;
66 m_xConnections
.push_back(uno::WeakReferenceHelper(*pCon
));
71 sal_Bool SAL_CALL
ODriver::acceptsURL(const OUString
& url
) throw(sdbc::SQLException
, uno::RuntimeException
, std::exception
)
73 return url
.startsWith("sdbc:writer:");
76 uno::Sequence
< sdbc::DriverPropertyInfo
> SAL_CALL
ODriver::getPropertyInfo(const OUString
& url
, const uno::Sequence
< beans::PropertyValue
>& /*info*/) throw(sdbc::SQLException
, uno::RuntimeException
, std::exception
)
80 SharedResources aResources
;
81 const OUString sMessage
= aResources
.getResourceString(STR_URI_SYNTAX_ERROR
);
82 ::dbtools::throwGenericSQLException(sMessage
,*this);
84 return uno::Sequence
< sdbc::DriverPropertyInfo
>();
88 } // namespace connectivity
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */