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