bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / ui / inc / directsql.hxx
blob0c10fc9b330d856df51e1f956a1f0ad7767fa718
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef _DBACCESS_UI_DIRECTSQL_HXX_
21 #define _DBACCESS_UI_DIRECTSQL_HXX_
23 #include <vcl/dialog.hxx>
24 #include <svtools/editsyntaxhighlighter.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <vcl/button.hxx>
28 #include <comphelper/stl_types.hxx>
29 #include <deque>
31 #include <com/sun/star/sdbc/XConnection.hpp>
32 #include <unotools/eventlisteneradapter.hxx>
33 #include "moduledbu.hxx"
34 #include <osl/mutex.hxx>
36 #include <svtools/editbrowsebox.hxx>
38 //........................................................................
39 namespace dbaui
41 //........................................................................
43 //====================================================================
44 //= DirectSQLDialog
45 //====================================================================
46 class DirectSQLDialog
47 :public ModalDialog
48 ,public ::utl::OEventListenerAdapter
50 protected:
51 OModuleClient m_aModuleClient;
52 ::osl::Mutex m_aMutex;
54 FixedLine m_aFrame;
55 FixedText m_aSQLLabel;
56 MultiLineEditSyntaxHighlight m_aSQL;
57 PushButton m_aExecute;
58 FixedText m_aHistoryLabel;
59 ListBox* m_pSQLHistory;
60 FixedLine m_aStatusFrame;
61 MultiLineEdit m_aStatus;
62 CheckBox* m_pShowOutput;
63 FixedLine m_aOutputFrame;
64 MultiLineEdit m_aOutput;
65 FixedLine m_aButtonSeparator;
66 HelpButton m_aHelp;
67 PushButton m_aClose;
69 typedef ::std::deque< String > StringQueue;
70 StringQueue m_aStatementHistory; // previous statements
71 StringQueue m_aNormalizedHistory; // previous statements, normalized to be used in the list box
73 sal_Int32 m_nHistoryLimit;
74 sal_Int32 m_nStatusCount;
76 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
77 m_xConnection;
79 public:
80 DirectSQLDialog(
81 Window* _pParent,
82 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn);
83 ~DirectSQLDialog();
85 /// number of history entries
86 sal_Int32 getHistorySize() const;
88 protected:
89 void executeCurrent();
90 void switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox = sal_True);
92 // OEventListenerAdapter
93 virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
95 protected:
96 DECL_LINK( OnExecute, void* );
97 DECL_LINK( OnClose, void* );
98 DECL_LINK( OnListEntrySelected, void* );
99 DECL_LINK( OnStatementModified, void* );
101 private:
102 /// adds a statement to the statement history
103 void implAddToStatementHistory(const String& _rStatement);
105 /// ensures that our history has at most m_nHistoryLimit entries
106 void implEnsureHistoryLimit();
108 /// executes the statement given, adds the status to the status list
109 void implExecuteStatement(const String& _rStatement);
111 /// adds a status text to the status list
112 void addStatusText(const String& _rMessage);
114 /// adds a status text to the output list
115 void addOutputText(const String& _rMessage);
117 #ifdef DBG_UTIL
118 const sal_Char* impl_CheckInvariants() const;
119 #endif
122 //====================================================================
123 #ifdef DBG_UTIL
124 #define CHECK_INVARIANTS(methodname) \
126 const sal_Char* pError = impl_CheckInvariants(); \
127 if (pError) \
128 SAL_WARN("dbaccess.ui", methodname << ": " << pError); \
130 #else
131 #define CHECK_INVARIANTS(methodname)
132 #endif
134 //........................................................................
135 } // namespace dbaui
136 //........................................................................
138 #endif // _DBACCESS_UI_DIRECTSQL_HXX_
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */