1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <cppuhelper/implbase.hxx>
23 #include <connectivity/CommonTools.hxx>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/task/XInteractionHandler2.hpp>
29 #include <com/sun/star/sdb/ParametersRequest.hpp>
30 #include <com/sun/star/sdb/DocumentSaveRequest.hpp>
32 namespace com::sun::star::uno
{ class XComponentContext
; }
36 class SQLExceptionInfo
;
42 // BasicInteractionHandler
43 typedef ::cppu::WeakImplHelper
< css::lang::XServiceInfo
44 , css::lang::XInitialization
45 , css::task::XInteractionHandler2
46 > BasicInteractionHandler_Base
;
47 /** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for
48 database related interaction requests.
50 Supported interaction requests by now (specified by an exception: The appropriate exception
51 has to be returned by the getRequest method of the object implementing the
52 <type scope="com.sun.star.task">XInteractionRequest</type> interface.
54 <li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a
55 standard error dialog for the (maybe chained) exception given</li>
58 class BasicInteractionHandler
59 :public BasicInteractionHandler_Base
61 css::uno::Reference
< css::awt::XWindow
> m_xParentWindow
;
62 const css::uno::Reference
< css::uno::XComponentContext
>
64 const bool m_bFallbackToGeneric
;
67 BasicInteractionHandler(
68 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
69 const bool i_bFallbackToGeneric
73 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& rArgs
) override
;
75 // XInteractionHandler2
76 virtual sal_Bool SAL_CALL
handleInteractionRequest( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
78 // XInteractionHandler
79 virtual void SAL_CALL
handle( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
83 impl_handle_throw( const css::uno::Reference
< css::task::XInteractionRequest
>& i_Request
);
85 /// handle SQLExceptions (and derived classes)
86 static void implHandle(
87 const ::dbtools::SQLExceptionInfo
& _rSqlInfo
,
88 const css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> >& _rContinuations
);
90 /// handle parameter requests
92 const css::sdb::ParametersRequest
& _rParamRequest
,
93 const css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> >& _rContinuations
);
95 /// handle document save requests
97 const css::sdb::DocumentSaveRequest
& _rParamRequest
,
98 const css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> >& _rContinuations
);
100 /// handles requests which are not SDB-specific
101 bool implHandleUnknown(
102 const css::uno::Reference
< css::task::XInteractionRequest
>& _rxRequest
);
104 /// known continuation types
114 /** check if a given continuation sequence contains a given continuation type<p/>
115 @return the index within <arg>_rContinuations</arg> of the first occurrence of a continuation
116 of the requested type, -1 of no such continuation exists
118 static sal_Int32
getContinuation(
120 const css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> >& _rContinuations
);
123 // SQLExceptionInteractionHandler
124 class SQLExceptionInteractionHandler
: public BasicInteractionHandler
127 explicit SQLExceptionInteractionHandler(
128 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
130 :BasicInteractionHandler( rxContext
, false )
135 DECLARE_SERVICE_INFO();
138 // SQLExceptionInteractionHandler
139 /** an implementation for the legacy css.sdb.InteractionHandler
141 css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions,
142 but also delegates all kind of unknown requests to a css.task.InteractionHandler.
144 In today's architecture, there's only one central css.task.InteractionHandler, which is to be used
145 for all requests. Depending on configuration information, it decides which handler implementation
146 to delegate a request to.
148 SQLExceptionInteractionHandler is the delegatee which handles only database related interactions.
149 LegacyInteractionHandler is the version which first checks for a database related interaction, and
150 forwards everything else to the css.task.InteractionHandler.
152 class LegacyInteractionHandler
: public BasicInteractionHandler
155 explicit LegacyInteractionHandler(
156 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
158 :BasicInteractionHandler( rxContext
, true )
163 DECLARE_SERVICE_INFO();
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */