1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: directsql.hxx,v $
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>
38 #include <svtools/editsyntaxhighlighter.hxx>
41 #include <vcl/fixed.hxx>
43 #ifndef _SV_LSTBOX_HXX
44 #include <vcl/lstbox.hxx>
46 #ifndef _SV_BUTTON_HXX
47 #include <vcl/button.hxx>
49 #ifndef _COMPHELPER_STLTYPES_HXX_
50 #include <comphelper/stl_types.hxx>
54 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
55 #include <com/sun/star/sdbc/XConnection.hpp>
57 #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
58 #include <unotools/eventlisteneradapter.hxx>
60 #ifndef _DBAUI_MODULE_DBU_HXX_
61 #include "moduledbu.hxx"
63 #ifndef _OSL_MUTEX_HXX_
64 #include <osl/mutex.hxx>
67 //........................................................................
70 //........................................................................
72 //====================================================================
74 //====================================================================
77 ,public ::utl::OEventListenerAdapter
80 OModuleClient m_aModuleClient
;
81 ::osl::Mutex m_aMutex
;
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
;
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
>
108 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConn
);
111 /// add an history entry
112 void addHistoryEntry(const String
& _rStatement
);
114 /// number of history entries
115 sal_Int32
getHistorySize() const;
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
);
125 DECL_LINK( OnExecute
, void* );
126 DECL_LINK( OnClose
, void* );
127 DECL_LINK( OnListEntrySelected
, void* );
128 DECL_LINK( OnStatementModified
, void* );
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
);
144 const sal_Char
* impl_CheckInvariants() const;
148 //====================================================================
150 #define CHECK_INVARIANTS(methodname) \
152 const sal_Char* pError = impl_CheckInvariants(); \
154 OSL_ENSURE(sal_False, (ByteString(methodname) += ByteString(": ") += ByteString(pError)).GetBuffer()); \
157 #define CHECK_INVARIANTS(methodname)
160 //........................................................................
162 //........................................................................
164 #endif // _DBACCESS_UI_DIRECTSQL_HXX_