1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _DBAUI_INTERACTION_HXX_
30 #define _DBAUI_INTERACTION_HXX_
32 #include <cppuhelper/implbase2.hxx>
34 #include "moduledbu.hxx"
35 #include "apitools.hxx"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/task/XInteractionHandler2.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/ucb/AuthenticationRequest.hpp>
42 #include <com/sun/star/sdb/ParametersRequest.hpp>
43 #include <com/sun/star/sdb/DocumentSaveRequest.hpp>
44 /** === end UNO includes === **/
48 class SQLExceptionInfo
;
51 //.........................................................................
54 //.........................................................................
56 //=========================================================================
57 //= BasicInteractionHandler
58 //=========================================================================
59 typedef ::cppu::WeakImplHelper2
< ::com::sun::star::lang::XServiceInfo
60 , ::com::sun::star::task::XInteractionHandler2
61 > BasicInteractionHandler_Base
;
62 /** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for
63 database related interaction requests.
65 Supported interaction requests by now (specified by an exception: The appropriate exception
66 has to be returned by the getRequest method of the object implementing the
67 <type scope="com.sun.star.task">XInteractionRequest</type> interface.
69 <li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a
70 standard error dialog for the (maybe chained) exception given</li>
73 class BasicInteractionHandler
74 :public BasicInteractionHandler_Base
76 const OModuleClient m_aModuleClient
;
77 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
79 const bool m_bFallbackToGeneric
;
82 BasicInteractionHandler(
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& i_rORB
,
84 const bool i_bFallbackToGeneric
87 // XInteractionHandler2
88 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 // XInteractionHandler
91 virtual void SAL_CALL
handle( const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionRequest
>& Request
) throw(::com::sun::star::uno::RuntimeException
);
95 impl_handle_throw( const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionRequest
>& i_Request
);
97 /// handle SQLExceptions (and derived classes)
99 const ::dbtools::SQLExceptionInfo
& _rSqlInfo
,
100 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >& _rContinuations
);
102 /// handle parameter requests
104 const ::com::sun::star::sdb::ParametersRequest
& _rParamRequest
,
105 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >& _rContinuations
);
107 /// handle document save requests
109 const ::com::sun::star::sdb::DocumentSaveRequest
& _rParamRequest
,
110 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >& _rContinuations
);
112 /// handles requests which are not SDB-specific
113 bool implHandleUnknown(
114 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionRequest
>& _rxRequest
);
116 /// known continuation types
126 /** check if a given continuation sequence contains a given continuation type<p/>
127 @return the index within <arg>_rContinuations</arg> of the first occurrence of a continuation
128 of the requested type, -1 of no such continuation exists
130 sal_Int32
getContinuation(
132 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >& _rContinuations
);
135 //=========================================================================
136 //= SQLExceptionInteractionHandler
137 //=========================================================================
138 class SQLExceptionInteractionHandler
: public BasicInteractionHandler
141 SQLExceptionInteractionHandler(
142 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& i_rORB
144 :BasicInteractionHandler( i_rORB
, false )
149 DECLARE_SERVICE_INFO_STATIC();
152 //=========================================================================
153 //= SQLExceptionInteractionHandler
154 //=========================================================================
155 /** an implementation for the legacy css.sdb.InteractionHandler
157 css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions,
158 but also delegates all kind of unknown requests to a css.task.InteractionHandler.
160 In today's architecture, there's only one central css.task.InteractionHandler, which is to be used
161 for all requests. Depending on configuration information, it decides which handler implementation
162 to delegate a request to.
164 SQLExceptionInteractionHandler is the delegatee which handles only database related interactions.
165 LegacyInteractionHandler is the version which first checks for a database related interaction, and
166 forwards everything else to the css.task.InteractionHandler.
168 class LegacyInteractionHandler
: public BasicInteractionHandler
171 LegacyInteractionHandler(
172 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& i_rORB
174 :BasicInteractionHandler( i_rORB
, true )
179 DECLARE_SERVICE_INFO_STATIC();
182 //.........................................................................
184 //.........................................................................
186 #endif // _DBAUI_INTERACTION_HXX_
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */