build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / ui / uno / dbinteraction.hxx
blob9e6184313974198f0f3d8ed1f4e7b38c93d630bd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_UNO_DBINTERACTION_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_UNO_DBINTERACTION_HXX
23 #include <cppuhelper/implbase.hxx>
25 #include "moduledbu.hxx"
26 #include "apitools.hxx"
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/task/XInteractionHandler2.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/ucb/AuthenticationRequest.hpp>
32 #include <com/sun/star/sdb/ParametersRequest.hpp>
33 #include <com/sun/star/sdb/DocumentSaveRequest.hpp>
35 namespace com { namespace sun { namespace star { namespace uno {
36 class XComponentContext;
37 } } } }
39 namespace dbtools
41 class SQLExceptionInfo;
44 namespace dbaui
47 // BasicInteractionHandler
48 typedef ::cppu::WeakImplHelper< css::lang::XServiceInfo
49 , css::task::XInteractionHandler2
50 > BasicInteractionHandler_Base;
51 /** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for
52 database related interaction requests.
53 <p/>
54 Supported interaction requests by now (specified by an exception: The appropriate exception
55 has to be returned by the getRequest method of the object implementing the
56 <type scope="com.sun.star.task">XInteractionRequest</type> interface.
57 <ul>
58 <li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a
59 standard error dialog for the (maybe chained) exception given</li>
60 </ul>
62 class BasicInteractionHandler
63 :public BasicInteractionHandler_Base
65 const OModuleClient m_aModuleClient;
66 const css::uno::Reference< css::uno::XComponentContext >
67 m_xContext;
68 const bool m_bFallbackToGeneric;
70 public:
71 BasicInteractionHandler(
72 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
73 const bool i_bFallbackToGeneric
76 // XInteractionHandler2
77 virtual sal_Bool SAL_CALL handleInteractionRequest( const css::uno::Reference< css::task::XInteractionRequest >& Request ) throw (css::uno::RuntimeException, std::exception) override;
79 // XInteractionHandler
80 virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& Request ) throw(css::uno::RuntimeException, std::exception) override;
82 protected:
83 bool
84 impl_handle_throw( const css::uno::Reference< css::task::XInteractionRequest >& i_Request );
86 /// handle SQLExceptions (and derived classes)
87 static void implHandle(
88 const ::dbtools::SQLExceptionInfo& _rSqlInfo,
89 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& _rContinuations);
91 /// handle parameter requests
92 void implHandle(
93 const css::sdb::ParametersRequest& _rParamRequest,
94 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& _rContinuations);
96 /// handle document save requests
97 void implHandle(
98 const css::sdb::DocumentSaveRequest& _rParamRequest,
99 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& _rContinuations);
101 /// handles requests which are not SDB-specific
102 bool implHandleUnknown(
103 const css::uno::Reference< css::task::XInteractionRequest >& _rxRequest );
105 /// known continuation types
106 enum Continuation
108 APPROVE,
109 DISAPPROVE,
110 RETRY,
111 ABORT,
112 SUPPLY_PARAMETERS,
113 SUPPLY_DOCUMENTSAVE
115 /** check if a given continuation sequence contains a given continuation type<p/>
116 @return the index within <arg>_rContinuations</arg> of the first occurrence of a continuation
117 of the requested type, -1 of no such continuation exists
119 static sal_Int32 getContinuation(
120 Continuation _eCont,
121 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& _rContinuations);
124 // SQLExceptionInteractionHandler
125 class SQLExceptionInteractionHandler : public BasicInteractionHandler
127 public:
128 explicit SQLExceptionInteractionHandler(
129 const css::uno::Reference< css::uno::XComponentContext >& rxContext
131 :BasicInteractionHandler( rxContext, false )
135 // XServiceInfo
136 DECLARE_SERVICE_INFO();
137 /// @throws css::uno::RuntimeException
138 static OUString SAL_CALL getImplementationName_Static( ) throw (css::uno::RuntimeException);
139 /// @throws css::uno::RuntimeException
140 static css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(css::uno::RuntimeException);
141 static css::uno::Reference< css::uno::XInterface >
142 SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >&);
145 // SQLExceptionInteractionHandler
146 /** an implementation for the legacy css.sdb.InteractionHandler
148 css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions,
149 but also delegates all kind of unknown requests to a css.task.InteractionHandler.
151 In today's architecture, there's only one central css.task.InteractionHandler, which is to be used
152 for all requests. Depending on configuration information, it decides which handler implementation
153 to delegate a request to.
155 SQLExceptionInteractionHandler is the delegatee which handles only database related interactions.
156 LegacyInteractionHandler is the version which first checks for a database related interaction, and
157 forwards everything else to the css.task.InteractionHandler.
159 class LegacyInteractionHandler : public BasicInteractionHandler
161 public:
162 explicit LegacyInteractionHandler(
163 const css::uno::Reference< css::uno::XComponentContext >& rxContext
165 :BasicInteractionHandler( rxContext, true )
169 // XServiceInfo
170 DECLARE_SERVICE_INFO();
171 /// @throws css::uno::RuntimeException
172 static OUString SAL_CALL getImplementationName_Static( ) throw (css::uno::RuntimeException);
173 /// @throws css::uno::RuntimeException
174 static css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(css::uno::RuntimeException);
175 static css::uno::Reference< css::uno::XInterface >
176 SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >&);
179 } // namespace dbaui
181 #endif // INCLUDED_DBACCESS_SOURCE_UI_UNO_DBINTERACTION_HXX
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */