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