Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / ui / inc / directsql.hxx
blobaba8f30d7e67328cd5373bf56c8d80c33f6c150c
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 INCLUDED_DBACCESS_SOURCE_UI_INC_DIRECTSQL_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_DIRECTSQL_HXX
23 #include <sal/config.h>
25 #include <sal/log.hxx>
26 #include <vcl/dialog.hxx>
27 #include <svtools/editsyntaxhighlighter.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <vcl/button.hxx>
31 #include <deque>
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #include <unotools/eventlisteneradapter.hxx>
35 #include "moduledbu.hxx"
36 #include <osl/mutex.hxx>
38 #include <svtools/editbrowsebox.hxx>
40 namespace dbaui
43 // DirectSQLDialog
44 class DirectSQLDialog
45 :public ModalDialog
46 ,public ::utl::OEventListenerAdapter
48 protected:
49 OModuleClient m_aModuleClient;
50 ::osl::Mutex m_aMutex;
52 VclPtr<MultiLineEditSyntaxHighlight> m_pSQL;
53 VclPtr<PushButton> m_pExecute;
54 VclPtr<ListBox> m_pSQLHistory;
55 VclPtr<VclMultiLineEdit> m_pStatus;
56 VclPtr<CheckBox> m_pShowOutput;
57 VclPtr<VclMultiLineEdit> m_pOutput;
58 VclPtr<PushButton> m_pClose;
60 typedef ::std::deque< OUString > StringQueue;
61 StringQueue m_aStatementHistory; // previous statements
62 StringQueue m_aNormalizedHistory; // previous statements, normalized to be used in the list box
64 sal_Int32 m_nHistoryLimit;
65 sal_Int32 m_nStatusCount;
67 css::uno::Reference< css::sdbc::XConnection >
68 m_xConnection;
70 public:
71 DirectSQLDialog(
72 vcl::Window* _pParent,
73 const css::uno::Reference< css::sdbc::XConnection >& _rxConn);
74 virtual ~DirectSQLDialog();
75 virtual void dispose() override;
77 /// number of history entries
78 sal_Int32 getHistorySize() const;
80 protected:
81 void executeCurrent();
82 void switchToHistory(sal_Int32 _nHistoryPos);
84 // OEventListenerAdapter
85 virtual void _disposing( const css::lang::EventObject& _rSource ) override;
87 protected:
88 DECL_LINK_TYPED( OnExecute, Button*, void );
89 DECL_LINK_TYPED( OnClose, void*, void );
90 DECL_LINK_TYPED( OnCloseClick, Button*, void );
91 DECL_LINK_TYPED( OnListEntrySelected, ListBox&, void );
92 DECL_LINK_TYPED( OnStatementModified, Edit&, void );
94 private:
95 /// adds a statement to the statement history
96 void implAddToStatementHistory(const OUString& _rStatement);
98 /// ensures that our history has at most m_nHistoryLimit entries
99 void implEnsureHistoryLimit();
101 /// executes the statement given, adds the status to the status list
102 void implExecuteStatement(const OUString& _rStatement);
104 /// adds a status text to the status list
105 void addStatusText(const OUString& _rMessage);
107 /// adds a status text to the output list
108 void addOutputText(const OUString& _rMessage);
110 #ifdef DBG_UTIL
111 const sal_Char* impl_CheckInvariants() const;
112 #endif
115 #ifdef DBG_UTIL
116 #define CHECK_INVARIANTS(methodname) \
118 const sal_Char* pError = impl_CheckInvariants(); \
119 if (pError) \
120 SAL_WARN("dbaccess.ui", methodname ": " << pError); \
122 #else
123 #define CHECK_INVARIANTS(methodname)
124 #endif
126 } // namespace dbaui
128 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DIRECTSQL_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */