1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 #ifndef DBAUI_QUERYVIEW_TEXT_HXX 31 #include "QueryTextView.hxx" 32 #endif 33 #ifndef DBAUI_QUERYCONTAINERWINDOW_HXX 34 #include "querycontainerwindow.hxx" 35 #endif 36 #ifndef DBAUI_QUERYVIEWSWITCH_HXX 37 #include "QueryViewSwitch.hxx" 38 #endif 39 #ifndef DBAUI_SQLEDIT_HXX 40 #include "sqledit.hxx" 41 #endif 42 #ifndef DBAUI_UNDOSQLEDIT_HXX 43 #include "undosqledit.hxx" 44 #endif 45 #ifndef DBACCESS_UI_BROWSER_ID_HXX 46 #include "browserids.hxx" 47 #endif 48 #ifndef DBAUI_QUERYCONTROLLER_HXX 49 #include "querycontroller.hxx" 50 #endif 51 #ifndef _DBU_QRY_HRC_ 52 #include "dbu_qry.hrc" 53 #endif 54 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 55 #include "dbustrings.hrc" 56 #endif 57 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 58 #include <toolkit/unohlp.hxx> 59 #endif 60 #ifndef _SV_SPLIT_HXX 61 #include <vcl/split.hxx> 62 #endif 63 #ifndef _SV_SVAPP_HXX 64 #include <vcl/svapp.hxx> 65 #endif 66 #ifndef _COMPHELPER_TYPES_HXX_ 67 #include <comphelper/types.hxx> 68 #endif 69 #ifndef DBAUI_QUERYDESIGNVIEW_HXX 70 #include "QueryDesignView.hxx" 71 #endif 72 73 using namespace dbaui; 74 using namespace ::com::sun::star::uno; 75 using namespace ::com::sun::star::lang; 76 using namespace ::com::sun::star::frame; 77 // ----------------------------------------------------------------------------- 78 79 // end of temp classes 80 // ------------------------------------------------------------------------- 81 DBG_NAME(OQueryTextView) 82 OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent) 83 :Window(_pParent) 84 { 85 DBG_CTOR(OQueryTextView,NULL); 86 m_pEdit = new OSqlEdit(this); 87 m_pEdit->SetRightToLeft(sal_False); 88 m_pEdit->ClearModifyFlag(); 89 m_pEdit->SaveValue(); 90 m_pEdit->SetPosPixel( Point( 0, 0 ) ); 91 m_pEdit->Show(); 92 // m_pEdit->GrabFocus(); 93 } 94 // ----------------------------------------------------------------------------- 95 OQueryTextView::~OQueryTextView() 96 { 97 DBG_DTOR(OQueryTextView,NULL); 98 ::std::auto_ptr<Window> aTemp(m_pEdit); 99 m_pEdit = NULL; 100 } 101 // ----------------------------------------------------------------------------- 102 void OQueryTextView::GetFocus() 103 { 104 if ( m_pEdit ) 105 m_pEdit->GrabFocus(); 106 } 107 // ------------------------------------------------------------------------- 108 void OQueryTextView::Resize() 109 { 110 Window::Resize(); 111 m_pEdit->SetSizePixel( GetOutputSizePixel() ); 112 } 113 // ----------------------------------------------------------------------------- 114 // check if the statement is correct when not returning false 115 sal_Bool OQueryTextView::checkStatement() 116 { 117 return sal_True; 118 } 119 // ----------------------------------------------------------------------------- 120 ::rtl::OUString OQueryTextView::getStatement() 121 { 122 return m_pEdit->GetText(); 123 } 124 // ----------------------------------------------------------------------------- 125 void OQueryTextView::setReadOnly(sal_Bool _bReadOnly) 126 { 127 m_pEdit->SetReadOnly(_bReadOnly); 128 } 129 // ----------------------------------------------------------------------------- 130 void OQueryTextView::clear() 131 { 132 OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit ); 133 134 pUndoAct->SetOriginalText( m_pEdit->GetText() ); 135 getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct ); 136 137 m_pEdit->SetText(String()); 138 } 139 // ----------------------------------------------------------------------------- 140 void OQueryTextView::setStatement(const ::rtl::OUString& _rsStatement) 141 { 142 m_pEdit->SetText(_rsStatement); 143 } 144 // ----------------------------------------------------------------------------- 145 void OQueryTextView::copy() 146 { 147 if(!m_pEdit->IsInAccelAct() ) 148 m_pEdit->Copy(); 149 } 150 // ----------------------------------------------------------------------------- 151 sal_Bool OQueryTextView::isCutAllowed() 152 { 153 return m_pEdit->GetSelected().Len() != 0; 154 } 155 // ----------------------------------------------------------------------------- 156 sal_Bool OQueryTextView::isPasteAllowed() 157 { 158 return sal_True; 159 } 160 // ----------------------------------------------------------------------------- 161 sal_Bool OQueryTextView::isCopyAllowed() 162 { 163 return sal_True; 164 } 165 // ----------------------------------------------------------------------------- 166 void OQueryTextView::cut() 167 { 168 if(!m_pEdit->IsInAccelAct() ) 169 m_pEdit->Cut(); 170 getContainerWindow()->getDesignView()->getController().setModified(sal_True); 171 } 172 // ----------------------------------------------------------------------------- 173 void OQueryTextView::paste() 174 { 175 if(!m_pEdit->IsInAccelAct() ) 176 m_pEdit->Paste(); 177 getContainerWindow()->getDesignView()->getController().setModified(sal_True); 178 } 179 // ----------------------------------------------------------------------------- 180