xref: /trunk/main/dbaccess/source/ui/inc/sqlmessage.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBAUI_SQLMESSAGE_HXX_
29 #define _DBAUI_SQLMESSAGE_HXX_
30 
31 #ifndef _BUTTON_HXX
32 #include <vcl/button.hxx>
33 #endif
34 #ifndef _FIXED_HXX
35 #include <vcl/fixed.hxx>
36 #endif
37 #ifndef _SV_BTNDLG_HXX
38 #include <vcl/btndlg.hxx>
39 #endif
40 
41 #ifndef _DBHELPER_DBEXCEPTION_HXX_
42 #include <connectivity/dbexception.hxx>
43 #endif
44 
45 #include <memory>
46 
47 // some forwards
48 namespace com { namespace sun { namespace star {
49 	namespace sdb {
50 		class SQLContext;
51 	}
52 	namespace sdbc {
53 		class SQLException;
54 	}
55 } } }
56 
57 //.........................................................................
58 namespace dbaui
59 {
60 //.........................................................................
61 
62 //==================================================================
63 // OSQLMessageBox
64 //==================================================================
65 struct SQLMessageBox_Impl;
66 class OSQLMessageBox : public ButtonDialog
67 {
68 	FixedImage		m_aInfoImage;
69 	FixedText		m_aTitle;
70 	FixedText		m_aMessage;
71     ::rtl::OUString m_sHelpURL;
72 
73     ::std::auto_ptr< SQLMessageBox_Impl >   m_pImpl;
74 
75 public:
76 	enum MessageType
77 	{
78 		Info,
79 		Error,
80 		Warning,
81 		Query,
82 
83         AUTO
84 	};
85 
86 public:
87 	/**	display an SQLException with auto-recognizing a main and a detailed message
88 
89         The first two messages from the exception chain are used as main and detailed message (recognizing the
90 		detailed field of an <type scope="com::sun::star::sdb">SQLContext</type>).
91 	*/
92 	OSQLMessageBox(
93         Window* _pParent,
94 		const dbtools::SQLExceptionInfo& _rException,
95         WinBits _nStyle = WB_OK | WB_DEF_OK,
96         const ::rtl::OUString& _rHelpURL = ::rtl::OUString()
97     );
98 
99 	/**	display a database related error message
100 
101         @param	rTitle		the title to display
102 		@param	rMessage	the detailed message to display
103         @param  _eType      determines the image to use. AUTO is disallowed in this constructor version
104 	*/
105 	OSQLMessageBox(Window* pParent,
106 				const UniString& rTitle,
107 				const UniString& rMessage,
108 				WinBits nStyle = WB_OK | WB_DEF_OK,
109 				MessageType _eType = Info,
110                 const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = NULL );
111 
112     ~OSQLMessageBox();
113 
114 private:
115     void Construct( WinBits nStyle, MessageType eImage );
116 
117 	DECL_LINK(ButtonClickHdl, Button* );
118 
119 private:
120     void    impl_positionControls();
121     void    impl_initImage( MessageType _eImage );
122     void    impl_createStandardButtons( WinBits _nStyle );
123     void    impl_addDetailsButton();
124 };
125 
126 //==================================================================
127 // OSQLWarningBox
128 //==================================================================
129 class OSQLWarningBox : public OSQLMessageBox
130 {
131 public:
132 	OSQLWarningBox( Window* _pParent,
133 				    const UniString& _rMessage,
134 				    WinBits _nStyle = WB_OK | WB_DEF_OK,
135                     const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = NULL );
136 };
137 
138 //.........................................................................
139 }	// namespace dbaui
140 //.........................................................................
141 
142 #endif // _DBAUI_SQLMESSAGE_HXX_
143 
144