Line data Source code
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 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DATASOURCECONNECTOR_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_DATASOURCECONNECTOR_HXX
22 :
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/uno/XComponentContext.hpp>
25 : #include <com/sun/star/sdbc/XConnection.hpp>
26 : #include <com/sun/star/sdbc/XDataSource.hpp>
27 : #include <vcl/vclptr.hxx>
28 :
29 : namespace dbtools
30 : {
31 : class SQLExceptionInfo;
32 : }
33 :
34 : namespace vcl { class Window; }
35 : namespace dbaui
36 : {
37 :
38 : // ODatasourceConnector
39 1 : class ODatasourceConnector
40 : {
41 : protected:
42 : VclPtr<vcl::Window> m_pErrorMessageParent;
43 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
44 : m_xContext;
45 : OUString m_sContextInformation;
46 :
47 : public:
48 : ODatasourceConnector(
49 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
50 : vcl::Window* _pMessageParent
51 : );
52 : ODatasourceConnector(
53 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
54 : vcl::Window* _pMessageParent,
55 : const OUString& _rContextInformation
56 : );
57 :
58 : /// returns <TRUE/> if the object is able to create data source connections
59 2 : bool isValid() const { return m_xContext.is(); }
60 :
61 : /** creates a connection to the data source, displays the possible error to the user, or returns it
62 : */
63 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
64 : connect(
65 : const OUString& _rDataSourceName,
66 : ::dbtools::SQLExceptionInfo* _pErrorInfo
67 : ) const;
68 :
69 : /** creates a connection to the data source, displays the possible error to the user, or returns it
70 : */
71 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
72 : connect(
73 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource,
74 : ::dbtools::SQLExceptionInfo* _pErrorInfo
75 : ) const;
76 : };
77 :
78 : } // namespace dbaui
79 :
80 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DATASOURCECONNECTOR_HXX
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|