1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
25 #define _DBAUI_DATASOURCECONNECTOR_HXX_
26 
27 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
28 #include <com/sun/star/container/XNameAccess.hpp>
29 #endif
30 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #endif
33 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
34 #include <com/sun/star/sdbc/XConnection.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
37 #include <com/sun/star/sdbc/XDataSource.hpp>
38 #endif
39 
40 namespace dbtools
41 {
42     class SQLExceptionInfo;
43 }
44 
45 class Window;
46 //.........................................................................
47 namespace dbaui
48 {
49 //.........................................................................
50 
51 	//=====================================================================
52 	//= ODatasourceConnector
53 	//=====================================================================
54 	class ODatasourceConnector
55 	{
56 	protected:
57 		Window*			m_pErrorMessageParent;
58 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
59 						m_xORB;
60 		::rtl::OUString	m_sContextInformation;
61 
62 	public:
63 		ODatasourceConnector(
64 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
65 			Window* _pMessageParent
66 		);
67 		ODatasourceConnector(
68 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
69 			Window* _pMessageParent,
70 			const ::rtl::OUString& _rContextInformation
71 		);
72 
73 		/// returns <TRUE/> if the object is able to create data source connections
isValid() const74 		sal_Bool	isValid() const { return m_xORB.is(); }
75 
76 		/** creates a connection to the data source, displays the possible error to the user, or returns it
77         */
78 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
79 					connect(
80                         const ::rtl::OUString& _rDataSourceName,
81                         ::dbtools::SQLExceptionInfo* _pErrorInfo
82                     ) const;
83 
84 		/** creates a connection to the data source, displays the possible error to the user, or returns it
85         */
86 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
87 					connect(
88                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource,
89                         ::dbtools::SQLExceptionInfo* _pErrorInfo
90                     ) const;
91 	};
92 
93 //.........................................................................
94 }	// namespace dbaui
95 //.........................................................................
96 
97 #endif // _DBAUI_DATASOURCECONNECTOR_HXX_
98 
99