22#include <osl/diagnose.h>
25#include <com/sun/star/task/InteractionHandler.hpp>
26#include <com/sun/star/task/XInteractionApprove.hpp>
27#include <com/sun/star/task/XInteractionDisapprove.hpp>
28#include <com/sun/star/task/XInteractionRetry.hpp>
29#include <com/sun/star/task/XInteractionAbort.hpp>
30#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
31#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
38extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
40 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
42 return cppu::acquire(new ::dbaui::SQLExceptionInteractionHandler(context));
45extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
47 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
49 return cppu::acquire(new ::dbaui::LegacyInteractionHandler(context));
65 ,m_bFallbackToGeneric( i_bFallbackToGeneric )
68 "BasicInteractionHandler::BasicInteractionHandler: enabling legacy behavior, there should be no clients of this anymore!" );
89 Any aRequest( i_Request->getRequest() );
90 OSL_ENSURE(aRequest.hasValue(),
"BasicInteractionHandler::handle: invalid request!");
91 if ( !aRequest.hasValue() )
105 ParametersRequest aParamRequest;
106 if ( aRequest >>= aParamRequest )
112 DocumentSaveRequest aDocuRequest;
113 if ( aRequest >>= aDocuRequest )
135 xParamCallback.set(_rContinuations[nParamPos], UNO_QUERY);
136 OSL_ENSURE(xParamCallback.is(),
"BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s");
139 sal_Int16 nResult = aDlg.run();
145 if (xParamCallback.is())
147 xParamCallback->setParameters(aDlg.getValues());
148 xParamCallback->select();
153 _rContinuations[nAbortPos]->select();
157 catch(
const Exception& )
175 bool bHaveCancel = nAbortPos != -1;
178 if ( ( nApprovePos != -1 ) || ( nDisapprovePos != -1 ) )
187 if ( nRetryPos != -1 )
193 OSQLMessageBox aDialog(
nullptr, _rSqlInfo, nDialogStyle);
195 sal_Int16 nResult = aDialog.run();
202 if ( nApprovePos != -1 )
203 _rContinuations[ nApprovePos ]->select();
205 OSL_ENSURE( nResult != RET_YES,
"BasicInteractionHandler::implHandle: no handler for YES!" );
209 if ( nDisapprovePos != -1 )
210 _rContinuations[ nDisapprovePos ]->select();
212 OSL_FAIL(
"BasicInteractionHandler::implHandle: no handler for NO!" );
216 if ( nAbortPos != -1 )
217 _rContinuations[ nAbortPos ]->select();
218 else if ( nDisapprovePos != -1 )
219 _rContinuations[ nDisapprovePos ]->select();
221 OSL_FAIL(
"BasicInteractionHandler::implHandle: no handler for CANCEL!" );
224 if ( nRetryPos != -1 )
225 _rContinuations[ nRetryPos ]->select();
227 OSL_FAIL(
"BasicInteractionHandler::implHandle: where does the RETRY come from?" );
231 catch(
const Exception& )
246 if ( -1 != nApprovePos )
252 if ( RET_CANCEL == nRet )
255 _rContinuations[nAbortPos]->select();
258 else if ( RET_YES == nRet )
264 Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY);
265 OSL_ENSURE(xCallback.is(),
"BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s");
268 sal_Int16 nResult = aDlg.run();
276 xCallback->setName(aDlg.getName(), aDlg.getSelectedFolder());
282 _rContinuations[nAbortPos]->select();
286 catch(
const Exception& )
291 else if ( -1 != nApprovePos )
292 _rContinuations[nApprovePos]->select();
294 else if ( -1 != nDisApprovePos )
295 _rContinuations[nDisApprovePos]->select();
303 InteractionHandler::createWithParent(
m_xContext,
nullptr) );
304 xFallbackHandler->handle( _rxRequest );
313 for (sal_Int32
i=0;
i<_rContinuations.getLength(); ++
i, ++pContinuations)
348 OUString SAL_CALL SQLExceptionInteractionHandler::getImplementationName()
350 return "com.sun.star.comp.dbaccess.DatabaseInteractionHandler";
352 sal_Bool SAL_CALL SQLExceptionInteractionHandler::supportsService(
const OUString& _rServiceName)
355 for (
const OUString& s : aSupported)
356 if (s == _rServiceName)
361 css::uno::Sequence< OUString > SAL_CALL SQLExceptionInteractionHandler::getSupportedServiceNames()
363 return {
"com.sun.star.sdb.DatabaseInteractionHandler" };
367 OUString SAL_CALL LegacyInteractionHandler::getImplementationName()
369 return "com.sun.star.comp.dbaccess.LegacyInteractionHandler";
371 sal_Bool SAL_CALL LegacyInteractionHandler::supportsService(
const OUString& _rServiceName)
374 for (
const OUString& s : aSupported)
375 if (s == _rServiceName)
380 css::uno::Sequence< OUString > SAL_CALL LegacyInteractionHandler::getSupportedServiceNames()
382 return {
"com.sun.star.sdb.InteractionHandler" };
SFX2_DLLPUBLIC short ExecuteQuerySaveDocument(weld::Widget *_pParent, std::u16string_view _rTitle)
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
const css::uno::Reference< css::uno::XComponentContext > m_xContext
static void implHandle(const ::dbtools::SQLExceptionInfo &_rSqlInfo, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &_rContinuations)
handle SQLExceptions (and derived classes)
bool impl_handle_throw(const css::uno::Reference< css::task::XInteractionRequest > &i_Request)
css::uno::Reference< css::awt::XWindow > m_xParentWindow
virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest > &Request) override
static sal_Int32 getContinuation(Continuation _eCont, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &_rContinuations)
check if a given continuation sequence contains a given continuation type
bool implHandleUnknown(const css::uno::Reference< css::task::XInteractionRequest > &_rxRequest)
handles requests which are not SDB-specific
const bool m_bFallbackToGeneric
Continuation
known continuation types
virtual sal_Bool SAL_CALL handleInteractionRequest(const css::uno::Reference< css::task::XInteractionRequest > &Request) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArgs) override
BasicInteractionHandler(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const bool i_bFallbackToGeneric)
Reference< XComponentContext > m_xContext
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dbaccess_DatabaseInteractionHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dbaccess_LegacyInteractionHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
#define DBG_UNHANDLED_EXCEPTION(...)
css::uno::Sequence< OUString > getSupportedServiceNames()
HashMap_OWString_Interface aMap