1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DBACCESS_UI_DIRECTSQL_HXX_ 25cdf0e10cSrcweir #define _DBACCESS_UI_DIRECTSQL_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _SV_DIALOG_HXX 28cdf0e10cSrcweir #include <vcl/dialog.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _SVEDIT_HXX 31cdf0e10cSrcweir #include <svtools/editsyntaxhighlighter.hxx> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _SV_FIXED_HXX 34cdf0e10cSrcweir #include <vcl/fixed.hxx> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _SV_LSTBOX_HXX 37cdf0e10cSrcweir #include <vcl/lstbox.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 40cdf0e10cSrcweir #include <vcl/button.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_ 43cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include <deque> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 48cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ 51cdf0e10cSrcweir #include <unotools/eventlisteneradapter.hxx> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 54cdf0e10cSrcweir #include "moduledbu.hxx" 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX_ 57cdf0e10cSrcweir #include <osl/mutex.hxx> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir 60cdf0e10cSrcweir //........................................................................ 61cdf0e10cSrcweir namespace dbaui 62cdf0e10cSrcweir { 63cdf0e10cSrcweir //........................................................................ 64cdf0e10cSrcweir 65cdf0e10cSrcweir //==================================================================== 66cdf0e10cSrcweir //= DirectSQLDialog 67cdf0e10cSrcweir //==================================================================== 68cdf0e10cSrcweir class DirectSQLDialog 69cdf0e10cSrcweir :public ModalDialog 70cdf0e10cSrcweir ,public ::utl::OEventListenerAdapter 71cdf0e10cSrcweir { 72cdf0e10cSrcweir protected: 73cdf0e10cSrcweir OModuleClient m_aModuleClient; 74cdf0e10cSrcweir ::osl::Mutex m_aMutex; 75cdf0e10cSrcweir 76cdf0e10cSrcweir FixedLine m_aFrame; 77cdf0e10cSrcweir FixedText m_aSQLLabel; 78cdf0e10cSrcweir MultiLineEditSyntaxHighlight m_aSQL; 79cdf0e10cSrcweir PushButton m_aExecute; 80cdf0e10cSrcweir FixedText m_aHistoryLabel; 81cdf0e10cSrcweir ListBox* m_pSQLHistory; 82cdf0e10cSrcweir FixedLine m_aStatusFrame; 83cdf0e10cSrcweir MultiLineEdit m_aStatus; 84cdf0e10cSrcweir FixedLine m_aButtonSeparator; 85cdf0e10cSrcweir HelpButton m_aHelp; 86cdf0e10cSrcweir PushButton m_aClose; 87cdf0e10cSrcweir 88cdf0e10cSrcweir typedef ::std::deque< String > StringQueue; 89cdf0e10cSrcweir StringQueue m_aStatementHistory; // previous statements 90cdf0e10cSrcweir StringQueue m_aNormalizedHistory; // previous statements, normalized to be used in the list box 91cdf0e10cSrcweir 92cdf0e10cSrcweir sal_Int32 m_nHistoryLimit; 93cdf0e10cSrcweir sal_Int32 m_nStatusCount; 94cdf0e10cSrcweir 95cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 96cdf0e10cSrcweir m_xConnection; 97cdf0e10cSrcweir 98cdf0e10cSrcweir public: 99cdf0e10cSrcweir DirectSQLDialog( 100cdf0e10cSrcweir Window* _pParent, 101cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn); 102cdf0e10cSrcweir ~DirectSQLDialog(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir /// number of history entries 105cdf0e10cSrcweir sal_Int32 getHistorySize() const; 106cdf0e10cSrcweir 107cdf0e10cSrcweir protected: 108cdf0e10cSrcweir void executeCurrent(); 109cdf0e10cSrcweir void switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox = sal_True); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // OEventListenerAdapter 112cdf0e10cSrcweir virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir protected: 115cdf0e10cSrcweir DECL_LINK( OnExecute, void* ); 116cdf0e10cSrcweir DECL_LINK( OnClose, void* ); 117cdf0e10cSrcweir DECL_LINK( OnListEntrySelected, void* ); 118cdf0e10cSrcweir DECL_LINK( OnStatementModified, void* ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir private: 121cdf0e10cSrcweir /// adds a statement to the statement history 122cdf0e10cSrcweir void implAddToStatementHistory(const String& _rStatement); 123cdf0e10cSrcweir 124cdf0e10cSrcweir /// ensures that our history has at most m_nHistoryLimit entries 125cdf0e10cSrcweir void implEnsureHistoryLimit(); 126cdf0e10cSrcweir 127cdf0e10cSrcweir /// executes the statement given, adds the status to the status list 128cdf0e10cSrcweir void implExecuteStatement(const String& _rStatement); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /// adds a status text to the status list 131cdf0e10cSrcweir void addStatusText(const String& _rMessage); 132cdf0e10cSrcweir 133cdf0e10cSrcweir #ifdef DBG_UTIL 134cdf0e10cSrcweir const sal_Char* impl_CheckInvariants() const; 135cdf0e10cSrcweir #endif 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir //==================================================================== 139cdf0e10cSrcweir #ifdef DBG_UTIL 140cdf0e10cSrcweir #define CHECK_INVARIANTS(methodname) \ 141cdf0e10cSrcweir { \ 142cdf0e10cSrcweir const sal_Char* pError = impl_CheckInvariants(); \ 143cdf0e10cSrcweir if (pError) \ 144cdf0e10cSrcweir OSL_ENSURE(sal_False, (ByteString(methodname) += ByteString(": ") += ByteString(pError)).GetBuffer()); \ 145cdf0e10cSrcweir } 146cdf0e10cSrcweir #else 147cdf0e10cSrcweir #define CHECK_INVARIANTS(methodname) 148cdf0e10cSrcweir #endif 149cdf0e10cSrcweir 150cdf0e10cSrcweir //........................................................................ 151cdf0e10cSrcweir } // namespace dbaui 152cdf0e10cSrcweir //........................................................................ 153cdf0e10cSrcweir 154cdf0e10cSrcweir #endif // _DBACCESS_UI_DIRECTSQL_HXX_ 155cdf0e10cSrcweir 156