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 <connectivity/dbexception.hxx>
23 #include <vcl/weld.hxx>
27 namespace com::sun::star
{
48 enum class MessBoxStyle
{
56 DefaultCancel
= 0x0040,
57 DefaultRetry
= 0x0080,
65 template<> struct typed_flags
<dbaui::MessBoxStyle
> : is_typed_flags
<dbaui::MessBoxStyle
, 0x03ff> {};
73 struct SQLMessageBox_Impl
;
74 class OSQLMessageBox
: public weld::DialogController
76 std::unique_ptr
<weld::MessageDialog
> m_xDialog
;
77 std::unique_ptr
<weld::Button
> m_xMoreButton
;
78 std::unique_ptr
<SQLMessageBox_Impl
> m_pImpl
;
81 virtual weld::Dialog
* getDialog() override
{ return m_xDialog
.get(); }
83 /** display an SQLException with auto-recognizing a main and a detailed message
85 The first two messages from the exception chain are used as main and detailed message (recognizing the
86 detailed field of an <type scope="css::sdb">SQLContext</type>).
89 weld::Window
* pParent
,
90 const dbtools::SQLExceptionInfo
& _rException
,
91 MessBoxStyle _nStyle
= MessBoxStyle::Ok
| MessBoxStyle::DefaultOk
,
92 OUString _sHelpURL
= OUString()
95 /** display a database related error message
97 @param rTitle the title to display
98 @param rMessage the detailed message to display
99 @param _eType determines the image to use. AUTO is disallowed in this constructor version
101 OSQLMessageBox(weld::Window
* pParent
,
102 const OUString
& rTitle
,
103 const OUString
& rMessage
,
104 MessBoxStyle nStyle
= MessBoxStyle::Ok
| MessBoxStyle::DefaultOk
,
105 MessageType _eType
= Info
,
106 const ::dbtools::SQLExceptionInfo
* _pAdditionalErrorInfo
= nullptr );
108 void set_title(const OUString
& rTitle
) { m_xDialog
->set_title(rTitle
); }
109 void add_button(const OUString
& rText
, int nResponse
, const OUString
& rHelpId
= {}) { m_xDialog
->add_button(rText
, nResponse
, rHelpId
); }
110 void set_default_response(int nResponse
) { m_xDialog
->set_default_response(nResponse
); }
112 virtual ~OSQLMessageBox() override
;
115 void Construct(weld::Window
* pParent
, MessBoxStyle nStyle
, MessageType eImage
);
117 DECL_LINK(ButtonClickHdl
, weld::Button
&, void);
120 void impl_fillMessages();
121 void impl_createStandardButtons( MessBoxStyle _nStyle
);
122 void impl_addDetailsButton();
126 class OSQLWarningBox
: public OSQLMessageBox
129 OSQLWarningBox( weld::Window
* pParent
,
130 const OUString
& _rMessage
,
131 MessBoxStyle _nStyle
= MessBoxStyle::Ok
| MessBoxStyle::DefaultOk
,
132 const ::dbtools::SQLExceptionInfo
* _pAdditionalErrorInfo
= nullptr );
136 class OSQLErrorBox
: public OSQLMessageBox
139 OSQLErrorBox( weld::Window
* pParent
,
140 const OUString
& _rMessage
);
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */