merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / directsql.hxx
blob752a5ec2a99ff15662952fdd06429856c34353a5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: directsql.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBACCESS_UI_DIRECTSQL_HXX_
32 #define _DBACCESS_UI_DIRECTSQL_HXX_
34 #ifndef _SV_DIALOG_HXX
35 #include <vcl/dialog.hxx>
36 #endif
37 #ifndef _SVEDIT_HXX
38 #include <svtools/editsyntaxhighlighter.hxx>
39 #endif
40 #ifndef _SV_FIXED_HXX
41 #include <vcl/fixed.hxx>
42 #endif
43 #ifndef _SV_LSTBOX_HXX
44 #include <vcl/lstbox.hxx>
45 #endif
46 #ifndef _SV_BUTTON_HXX
47 #include <vcl/button.hxx>
48 #endif
49 #ifndef _COMPHELPER_STLTYPES_HXX_
50 #include <comphelper/stl_types.hxx>
51 #endif
52 #include <deque>
54 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
55 #include <com/sun/star/sdbc/XConnection.hpp>
56 #endif
57 #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
58 #include <unotools/eventlisteneradapter.hxx>
59 #endif
60 #ifndef _DBAUI_MODULE_DBU_HXX_
61 #include "moduledbu.hxx"
62 #endif
63 #ifndef _OSL_MUTEX_HXX_
64 #include <osl/mutex.hxx>
65 #endif
67 //........................................................................
68 namespace dbaui
70 //........................................................................
72 //====================================================================
73 //= DirectSQLDialog
74 //====================================================================
75 class DirectSQLDialog
76 :public ModalDialog
77 ,public ::utl::OEventListenerAdapter
79 protected:
80 OModuleClient m_aModuleClient;
81 ::osl::Mutex m_aMutex;
83 FixedLine m_aFrame;
84 FixedText m_aSQLLabel;
85 MultiLineEditSyntaxHighlight m_aSQL;
86 PushButton m_aExecute;
87 FixedText m_aHistoryLabel;
88 ListBox* m_pSQLHistory;
89 FixedLine m_aStatusFrame;
90 MultiLineEdit m_aStatus;
91 FixedLine m_aButtonSeparator;
92 HelpButton m_aHelp;
93 PushButton m_aClose;
95 typedef ::std::deque< String > StringQueue;
96 StringQueue m_aStatementHistory; // previous statements
97 StringQueue m_aNormalizedHistory; // previous statements, normalized to be used in the list box
99 sal_Int32 m_nHistoryLimit;
100 sal_Int32 m_nStatusCount;
102 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
103 m_xConnection;
105 public:
106 DirectSQLDialog(
107 Window* _pParent,
108 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn);
109 ~DirectSQLDialog();
111 /// add an history entry
112 void addHistoryEntry(const String& _rStatement);
114 /// number of history entries
115 sal_Int32 getHistorySize() const;
117 protected:
118 void executeCurrent();
119 void switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox = sal_True);
121 // OEventListenerAdapter
122 virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
124 protected:
125 DECL_LINK( OnExecute, void* );
126 DECL_LINK( OnClose, void* );
127 DECL_LINK( OnListEntrySelected, void* );
128 DECL_LINK( OnStatementModified, void* );
130 private:
131 /// adds a statement to the statement history
132 void implAddToStatementHistory(const String& _rStatement);
134 /// ensures that our history has at most m_nHistoryLimit entries
135 void implEnsureHistoryLimit();
137 /// executes the statement given, adds the status to the status list
138 void implExecuteStatement(const String& _rStatement);
140 /// adds a status text to the status list
141 void addStatusText(const String& _rMessage);
143 #ifdef DBG_UTIL
144 const sal_Char* impl_CheckInvariants() const;
145 #endif
148 //====================================================================
149 #ifdef DBG_UTIL
150 #define CHECK_INVARIANTS(methodname) \
152 const sal_Char* pError = impl_CheckInvariants(); \
153 if (pError) \
154 OSL_ENSURE(sal_False, (ByteString(methodname) += ByteString(": ") += ByteString(pError)).GetBuffer()); \
156 #else
157 #define CHECK_INVARIANTS(methodname)
158 #endif
160 //........................................................................
161 } // namespace dbaui
162 //........................................................................
164 #endif // _DBACCESS_UI_DIRECTSQL_HXX_