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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir #ifndef DBAUI_QUERYVIEW_TEXT_HXX 31*cdf0e10cSrcweir #include "QueryTextView.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTAINERWINDOW_HXX 34*cdf0e10cSrcweir #include "querycontainerwindow.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef DBAUI_QUERYVIEWSWITCH_HXX 37*cdf0e10cSrcweir #include "QueryViewSwitch.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef DBAUI_SQLEDIT_HXX 40*cdf0e10cSrcweir #include "sqledit.hxx" 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef DBAUI_UNDOSQLEDIT_HXX 43*cdf0e10cSrcweir #include "undosqledit.hxx" 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX 46*cdf0e10cSrcweir #include "browserids.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTROLLER_HXX 49*cdf0e10cSrcweir #include "querycontroller.hxx" 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _DBU_QRY_HRC_ 52*cdf0e10cSrcweir #include "dbu_qry.hrc" 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 55*cdf0e10cSrcweir #include "dbustrings.hrc" 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 58*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir #ifndef _SV_SPLIT_HXX 61*cdf0e10cSrcweir #include <vcl/split.hxx> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX 64*cdf0e10cSrcweir #include <vcl/svapp.hxx> 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_ 67*cdf0e10cSrcweir #include <comphelper/types.hxx> 68*cdf0e10cSrcweir #endif 69*cdf0e10cSrcweir #ifndef DBAUI_QUERYDESIGNVIEW_HXX 70*cdf0e10cSrcweir #include "QueryDesignView.hxx" 71*cdf0e10cSrcweir #endif 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using namespace dbaui; 74*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 75*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 76*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 77*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // end of temp classes 80*cdf0e10cSrcweir // ------------------------------------------------------------------------- 81*cdf0e10cSrcweir DBG_NAME(OQueryTextView) 82*cdf0e10cSrcweir OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent) 83*cdf0e10cSrcweir :Window(_pParent) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir DBG_CTOR(OQueryTextView,NULL); 86*cdf0e10cSrcweir m_pEdit = new OSqlEdit(this); 87*cdf0e10cSrcweir m_pEdit->SetRightToLeft(sal_False); 88*cdf0e10cSrcweir m_pEdit->ClearModifyFlag(); 89*cdf0e10cSrcweir m_pEdit->SaveValue(); 90*cdf0e10cSrcweir m_pEdit->SetPosPixel( Point( 0, 0 ) ); 91*cdf0e10cSrcweir m_pEdit->Show(); 92*cdf0e10cSrcweir // m_pEdit->GrabFocus(); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 95*cdf0e10cSrcweir OQueryTextView::~OQueryTextView() 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir DBG_DTOR(OQueryTextView,NULL); 98*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pEdit); 99*cdf0e10cSrcweir m_pEdit = NULL; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 102*cdf0e10cSrcweir void OQueryTextView::GetFocus() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir if ( m_pEdit ) 105*cdf0e10cSrcweir m_pEdit->GrabFocus(); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir // ------------------------------------------------------------------------- 108*cdf0e10cSrcweir void OQueryTextView::Resize() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir Window::Resize(); 111*cdf0e10cSrcweir m_pEdit->SetSizePixel( GetOutputSizePixel() ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 114*cdf0e10cSrcweir // check if the statement is correct when not returning false 115*cdf0e10cSrcweir sal_Bool OQueryTextView::checkStatement() 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir return sal_True; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 120*cdf0e10cSrcweir ::rtl::OUString OQueryTextView::getStatement() 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir return m_pEdit->GetText(); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 125*cdf0e10cSrcweir void OQueryTextView::setReadOnly(sal_Bool _bReadOnly) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir m_pEdit->SetReadOnly(_bReadOnly); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 130*cdf0e10cSrcweir void OQueryTextView::clear() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir pUndoAct->SetOriginalText( m_pEdit->GetText() ); 135*cdf0e10cSrcweir getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir m_pEdit->SetText(String()); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 140*cdf0e10cSrcweir void OQueryTextView::setStatement(const ::rtl::OUString& _rsStatement) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir m_pEdit->SetText(_rsStatement); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 145*cdf0e10cSrcweir void OQueryTextView::copy() 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir if(!m_pEdit->IsInAccelAct() ) 148*cdf0e10cSrcweir m_pEdit->Copy(); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 151*cdf0e10cSrcweir sal_Bool OQueryTextView::isCutAllowed() 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir return m_pEdit->GetSelected().Len() != 0; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 156*cdf0e10cSrcweir sal_Bool OQueryTextView::isPasteAllowed() 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir return sal_True; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 161*cdf0e10cSrcweir sal_Bool OQueryTextView::isCopyAllowed() 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir return sal_True; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166*cdf0e10cSrcweir void OQueryTextView::cut() 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir if(!m_pEdit->IsInAccelAct() ) 169*cdf0e10cSrcweir m_pEdit->Cut(); 170*cdf0e10cSrcweir getContainerWindow()->getDesignView()->getController().setModified(sal_True); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 173*cdf0e10cSrcweir void OQueryTextView::paste() 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if(!m_pEdit->IsInAccelAct() ) 176*cdf0e10cSrcweir m_pEdit->Paste(); 177*cdf0e10cSrcweir getContainerWindow()->getDesignView()->getController().setModified(sal_True); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 180