/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// try to extract an SQLException (or one of its derived members
SQLExceptionInfo aInfo( aRequest ); if ( aInfo.isValid() )
{
implHandle( aInfo, aContinuations ); returntrue;
}
Reference< XInteractionSupplyParameters > xParamCallback; if (-1 != nParamPos)
xParamCallback.set(_rContinuations[nParamPos], UNO_QUERY);
OSL_ENSURE(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s");
// determine the style of the dialog, dependent on the present continuation types
MessBoxStyle nDialogStyle = MessBoxStyle::NONE; bool bHaveCancel = nAbortPos != -1; // "approve" means "Yes", "disapprove" means "No" // VCL only supports having both (which makes sense ...) if ( ( nApprovePos != -1 ) || ( nDisapprovePos != -1 ) )
nDialogStyle = ( bHaveCancel ? MessBoxStyle::YesNoCancel : MessBoxStyle::YesNo ) | MessBoxStyle::DefaultYes; else
{ // if there's no yes/no, then use a default OK button
nDialogStyle = ( bHaveCancel ? MessBoxStyle::OkCancel : MessBoxStyle::Ok ) | MessBoxStyle::DefaultOk;
}
// If there's a "Retry" continuation, have a "Retry" button if ( nRetryPos != -1 )
{
nDialogStyle = MessBoxStyle::RetryCancel | MessBoxStyle::DefaultRetry;
}
// execute the dialog
OSQLMessageBox aDialog(nullptr, _rSqlInfo, nDialogStyle); // TODO: need a way to specify the parent window
sal_Int16 nResult = aDialog.run(); try
{ switch (nResult)
{ case RET_YES: case RET_OK: if ( nApprovePos != -1 )
_rContinuations[ nApprovePos ]->select(); else
OSL_ENSURE( nResult != RET_YES, "BasicInteractionHandler::implHandle: no handler for YES!" ); break;
case RET_NO: if ( nDisapprovePos != -1 )
_rContinuations[ nDisapprovePos ]->select(); else
OSL_FAIL( "BasicInteractionHandler::implHandle: no handler for NO!" ); break;
case RET_CANCEL: if ( nAbortPos != -1 )
_rContinuations[ nAbortPos ]->select(); elseif ( nDisapprovePos != -1 )
_rContinuations[ nDisapprovePos ]->select(); else
OSL_FAIL( "BasicInteractionHandler::implHandle: no handler for CANCEL!" ); break; case RET_RETRY: if ( nRetryPos != -1 )
_rContinuations[ nRetryPos ]->select(); else
OSL_FAIL( "BasicInteractionHandler::implHandle: where does the RETRY come from?" ); break;
}
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
} void BasicInteractionHandler::implHandle(const DocumentSaveRequest& _rDocuRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
{
SolarMutexGuard aGuard; // want to open a dialog...
short nRet = RET_YES; if ( -1 != nApprovePos )
{ // ask whether it should be saved
nRet = ExecuteQuerySaveDocument(Application::GetFrameWeld(m_xParentWindow), _rDocuRequest.Name);
}
if (-1 != nDocuPos)
{
Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY);
OSL_ENSURE(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s");
sal_Int32 BasicInteractionHandler::getContinuation(Continuation _eCont, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
{ for (sal_Int32 i = 0; i < _rContinuations.getLength(); ++i)
{ switch (_eCont)
{ case APPROVE: if (Reference<XInteractionApprove>(_rContinuations[i], UNO_QUERY).is()) return i; break; case DISAPPROVE: if (Reference<XInteractionDisapprove>(_rContinuations[i], UNO_QUERY).is()) return i; break; case RETRY: if (Reference<XInteractionRetry>(_rContinuations[i], UNO_QUERY).is()) return i; break; case ABORT: if (Reference<XInteractionAbort>(_rContinuations[i], UNO_QUERY).is()) return i; break; case SUPPLY_PARAMETERS: if (Reference<XInteractionSupplyParameters>(_rContinuations[i], UNO_QUERY).is()) return i; break; case SUPPLY_DOCUMENTSAVE: if (Reference<XInteractionDocumentSave>(_rContinuations[i], UNO_QUERY).is()) return i; break;
}
}
return -1;
}
// SQLExceptionInteractionHandler
OUString SAL_CALL SQLExceptionInteractionHandler::getImplementationName()
{ return u"com.sun.star.comp.dbaccess.DatabaseInteractionHandler"_ustr;
}
sal_Bool SAL_CALL SQLExceptionInteractionHandler::supportsService(const OUString& _rServiceName)
{ const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames()); for (const OUString& s : aSupported) if (s == _rServiceName) returntrue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.