xref: /AOO41X/main/dbaccess/source/ui/uno/dbinteraction.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DBAUI_INTERACTION_HXX_
29*cdf0e10cSrcweir #define _DBAUI_INTERACTION_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE2_HXX_
32*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "moduledbu.hxx"
36*cdf0e10cSrcweir #include "apitools.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir /** === begin UNO includes === **/
39*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler2.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/ucb/AuthenticationRequest.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/sdb/ParametersRequest.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/sdb/DocumentSaveRequest.hpp>
45*cdf0e10cSrcweir /** === end UNO includes === **/
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace dbtools
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 	class SQLExceptionInfo;
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir //.........................................................................
53*cdf0e10cSrcweir namespace dbaui
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir //.........................................................................
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 	//=========================================================================
58*cdf0e10cSrcweir 	//= BasicInteractionHandler
59*cdf0e10cSrcweir 	//=========================================================================
60*cdf0e10cSrcweir 	typedef ::cppu::WeakImplHelper2	<	::com::sun::star::lang::XServiceInfo
61*cdf0e10cSrcweir 									,	::com::sun::star::task::XInteractionHandler2
62*cdf0e10cSrcweir 									>	BasicInteractionHandler_Base;
63*cdf0e10cSrcweir 	/** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for
64*cdf0e10cSrcweir 		database related interaction requests.
65*cdf0e10cSrcweir 		<p/>
66*cdf0e10cSrcweir 		Supported interaction requests by now (specified by an exception: The appropriate exception
67*cdf0e10cSrcweir 		has to be returned by the getRequest method of the object implementing the
68*cdf0e10cSrcweir 		<type scope="com.sun.star.task">XInteractionRequest</type> interface.
69*cdf0e10cSrcweir 			<ul>
70*cdf0e10cSrcweir 				<li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a
71*cdf0e10cSrcweir 					standard error dialog for the (maybe chained) exception given</li>
72*cdf0e10cSrcweir 			</ul>
73*cdf0e10cSrcweir 	*/
74*cdf0e10cSrcweir 	class BasicInteractionHandler
75*cdf0e10cSrcweir 				:public BasicInteractionHandler_Base
76*cdf0e10cSrcweir 	{
77*cdf0e10cSrcweir 		const OModuleClient m_aModuleClient;
78*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
79*cdf0e10cSrcweir 				            m_xORB;
80*cdf0e10cSrcweir         const bool          m_bFallbackToGeneric;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     public:
83*cdf0e10cSrcweir 		BasicInteractionHandler(
84*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB,
85*cdf0e10cSrcweir             const bool i_bFallbackToGeneric
86*cdf0e10cSrcweir         );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir         // XInteractionHandler2
89*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	    // XInteractionHandler
92*cdf0e10cSrcweir 		virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw(::com::sun::star::uno::RuntimeException);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	protected:
95*cdf0e10cSrcweir         sal_Bool
96*cdf0e10cSrcweir                 impl_handle_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_Request );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 		/// handle SQLExceptions (and derived classes)
99*cdf0e10cSrcweir 		void	implHandle(
100*cdf0e10cSrcweir 					const ::dbtools::SQLExceptionInfo& _rSqlInfo,
101*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 		/// handle parameter requests
104*cdf0e10cSrcweir 		void	implHandle(
105*cdf0e10cSrcweir 					const ::com::sun::star::sdb::ParametersRequest& _rParamRequest,
106*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 		/// handle document save requests
109*cdf0e10cSrcweir 		void	implHandle(
110*cdf0e10cSrcweir 					const ::com::sun::star::sdb::DocumentSaveRequest& _rParamRequest,
111*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir         /// handles requests which are not SDB-specific
114*cdf0e10cSrcweir         bool    implHandleUnknown(
115*cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& _rxRequest );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 		/// known continuation types
118*cdf0e10cSrcweir 		enum Continuation
119*cdf0e10cSrcweir 		{
120*cdf0e10cSrcweir 			APPROVE,
121*cdf0e10cSrcweir 			DISAPPROVE,
122*cdf0e10cSrcweir 			RETRY,
123*cdf0e10cSrcweir 			ABORT,
124*cdf0e10cSrcweir 			SUPPLY_PARAMETERS,
125*cdf0e10cSrcweir 			SUPPLY_DOCUMENTSAVE
126*cdf0e10cSrcweir 		};
127*cdf0e10cSrcweir 		/** check if a given continuation sequence contains a given continuation type<p/>
128*cdf0e10cSrcweir 			@return		the index within <arg>_rContinuations</arg> of the first occurence of a continuation
129*cdf0e10cSrcweir 						of the requested type, -1 of no such continuation exists
130*cdf0e10cSrcweir 		*/
131*cdf0e10cSrcweir 		sal_Int32 getContinuation(
132*cdf0e10cSrcweir 			Continuation _eCont,
133*cdf0e10cSrcweir 			const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
134*cdf0e10cSrcweir 	};
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	//=========================================================================
137*cdf0e10cSrcweir 	//= SQLExceptionInteractionHandler
138*cdf0e10cSrcweir 	//=========================================================================
139*cdf0e10cSrcweir     class SQLExceptionInteractionHandler : public BasicInteractionHandler
140*cdf0e10cSrcweir     {
141*cdf0e10cSrcweir     public:
142*cdf0e10cSrcweir         SQLExceptionInteractionHandler(
143*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
144*cdf0e10cSrcweir             )
145*cdf0e10cSrcweir             :BasicInteractionHandler( i_rORB, false )
146*cdf0e10cSrcweir         {
147*cdf0e10cSrcweir         }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         // XServiceInfo
150*cdf0e10cSrcweir 		DECLARE_SERVICE_INFO_STATIC();
151*cdf0e10cSrcweir     };
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	//=========================================================================
154*cdf0e10cSrcweir 	//= SQLExceptionInteractionHandler
155*cdf0e10cSrcweir 	//=========================================================================
156*cdf0e10cSrcweir     /** an implementation for the legacy css.sdb.InteractionHandler
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions,
159*cdf0e10cSrcweir         but also delegates all kind of unknown requests to a css.task.InteractionHandler.
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         In today's architecture, there's only one central css.task.InteractionHandler, which is to be used
162*cdf0e10cSrcweir         for all requests. Depending on configuration information, it decides which handler implementation
163*cdf0e10cSrcweir         to delegate a request to.
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         SQLExceptionInteractionHandler is the delegatee which handles only database related interactions.
166*cdf0e10cSrcweir         LegacyInteractionHandler is the version which first checks for a database related interaction, and
167*cdf0e10cSrcweir         forwards everything else to the css.task.InteractionHandler.
168*cdf0e10cSrcweir     */
169*cdf0e10cSrcweir     class LegacyInteractionHandler : public BasicInteractionHandler
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir     public:
172*cdf0e10cSrcweir         LegacyInteractionHandler(
173*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
174*cdf0e10cSrcweir             )
175*cdf0e10cSrcweir             :BasicInteractionHandler( i_rORB, true )
176*cdf0e10cSrcweir         {
177*cdf0e10cSrcweir         }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir         // XServiceInfo
180*cdf0e10cSrcweir 		DECLARE_SERVICE_INFO_STATIC();
181*cdf0e10cSrcweir     };
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir //.........................................................................
184*cdf0e10cSrcweir }	// namespace dbaui
185*cdf0e10cSrcweir //.........................................................................
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir #endif // _DBAUI_INTERACTION_HXX_
188*cdf0e10cSrcweir 
189