xref: /trunk/main/dbaccess/source/ui/inc/datasourceconnector.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
29 #define _DBAUI_DATASOURCECONNECTOR_HXX_
30 
31 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #endif
34 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
38 #include <com/sun/star/sdbc/XConnection.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
41 #include <com/sun/star/sdbc/XDataSource.hpp>
42 #endif
43 
44 namespace dbtools
45 {
46     class SQLExceptionInfo;
47 }
48 
49 class Window;
50 //.........................................................................
51 namespace dbaui
52 {
53 //.........................................................................
54 
55     //=====================================================================
56     //= ODatasourceConnector
57     //=====================================================================
58     class ODatasourceConnector
59     {
60     protected:
61         Window*         m_pErrorMessageParent;
62         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
63                         m_xORB;
64         ::rtl::OUString m_sContextInformation;
65 
66     public:
67         ODatasourceConnector(
68             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
69             Window* _pMessageParent
70         );
71         ODatasourceConnector(
72             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
73             Window* _pMessageParent,
74             const ::rtl::OUString& _rContextInformation
75         );
76 
77         /// returns <TRUE/> if the object is able to create data source connections
78         sal_Bool    isValid() const { return m_xORB.is(); }
79 
80         /** creates a connection to the data source, displays the possible error to the user, or returns it
81         */
82         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
83                     connect(
84                         const ::rtl::OUString& _rDataSourceName,
85                         ::dbtools::SQLExceptionInfo* _pErrorInfo
86                     ) const;
87 
88         /** creates a connection to the data source, displays the possible error to the user, or returns it
89         */
90         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
91                     connect(
92                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource,
93                         ::dbtools::SQLExceptionInfo* _pErrorInfo
94                     ) const;
95     };
96 
97 //.........................................................................
98 }   // namespace dbaui
99 //.........................................................................
100 
101 #endif // _DBAUI_DATASOURCECONNECTOR_HXX_
102 
103