1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 #ifndef DBAUI_QUERYVIEW_TEXT_HXX
27 #include "QueryTextView.hxx"
28 #endif
29 #ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
30 #include "querycontainerwindow.hxx"
31 #endif
32 #ifndef DBAUI_QUERYVIEWSWITCH_HXX
33 #include "QueryViewSwitch.hxx"
34 #endif
35 #ifndef DBAUI_SQLEDIT_HXX
36 #include "sqledit.hxx"
37 #endif
38 #ifndef DBAUI_UNDOSQLEDIT_HXX
39 #include "undosqledit.hxx"
40 #endif
41 #ifndef DBACCESS_UI_BROWSER_ID_HXX
42 #include "browserids.hxx"
43 #endif
44 #ifndef DBAUI_QUERYCONTROLLER_HXX
45 #include "querycontroller.hxx"
46 #endif
47 #ifndef _DBU_QRY_HRC_
48 #include "dbu_qry.hrc"
49 #endif
50 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
51 #include "dbustrings.hrc"
52 #endif
53 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
54 #include <toolkit/unohlp.hxx>
55 #endif
56 #ifndef _SV_SPLIT_HXX
57 #include <vcl/split.hxx>
58 #endif
59 #ifndef _SV_SVAPP_HXX
60 #include <vcl/svapp.hxx>
61 #endif
62 #ifndef _COMPHELPER_TYPES_HXX_
63 #include <comphelper/types.hxx>
64 #endif
65 #ifndef DBAUI_QUERYDESIGNVIEW_HXX
66 #include "QueryDesignView.hxx"
67 #endif
68 
69 using namespace dbaui;
70 using namespace ::com::sun::star::uno;
71 using namespace ::com::sun::star::lang;
72 using namespace ::com::sun::star::frame;
73 // -----------------------------------------------------------------------------
74 
75 // end of temp classes
76 // -------------------------------------------------------------------------
DBG_NAME(OQueryTextView)77 DBG_NAME(OQueryTextView)
78 OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
79 	:Window(_pParent)
80 {
81 	DBG_CTOR(OQueryTextView,NULL);
82 	m_pEdit = new OSqlEdit(this);
83 	m_pEdit->SetRightToLeft(sal_False);
84 	m_pEdit->ClearModifyFlag();
85 	m_pEdit->SaveValue();
86 	m_pEdit->SetPosPixel( Point( 0, 0 ) );
87 	m_pEdit->Show();
88 	//	m_pEdit->GrabFocus();
89 }
90 // -----------------------------------------------------------------------------
~OQueryTextView()91 OQueryTextView::~OQueryTextView()
92 {
93 	DBG_DTOR(OQueryTextView,NULL);
94 	::std::auto_ptr<Window> aTemp(m_pEdit);
95 	m_pEdit = NULL;
96 }
97 // -----------------------------------------------------------------------------
GetFocus()98 void OQueryTextView::GetFocus()
99 {
100 	if ( m_pEdit )
101 		m_pEdit->GrabFocus();
102 }
103 // -------------------------------------------------------------------------
Resize()104 void OQueryTextView::Resize()
105 {
106 	Window::Resize();
107 	m_pEdit->SetSizePixel( GetOutputSizePixel() );
108 }
109 // -----------------------------------------------------------------------------
110 // check if the statement is correct when not returning false
checkStatement()111 sal_Bool OQueryTextView::checkStatement()
112 {
113 	return sal_True;
114 }
115 // -----------------------------------------------------------------------------
getStatement()116 ::rtl::OUString OQueryTextView::getStatement()
117 {
118 	return m_pEdit->GetText();
119 }
120 // -----------------------------------------------------------------------------
setReadOnly(sal_Bool _bReadOnly)121 void OQueryTextView::setReadOnly(sal_Bool _bReadOnly)
122 {
123 	m_pEdit->SetReadOnly(_bReadOnly);
124 }
125 // -----------------------------------------------------------------------------
clear()126 void OQueryTextView::clear()
127 {
128 	OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
129 
130 	pUndoAct->SetOriginalText( m_pEdit->GetText() );
131 	getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
132 
133 	m_pEdit->SetText(String());
134 }
135 // -----------------------------------------------------------------------------
setStatement(const::rtl::OUString & _rsStatement)136 void OQueryTextView::setStatement(const ::rtl::OUString& _rsStatement)
137 {
138 	m_pEdit->SetText(_rsStatement);
139 }
140 // -----------------------------------------------------------------------------
copy()141 void OQueryTextView::copy()
142 {
143 	if(!m_pEdit->IsInAccelAct() )
144 		m_pEdit->Copy();
145 }
146 // -----------------------------------------------------------------------------
isCutAllowed()147 sal_Bool OQueryTextView::isCutAllowed()
148 {
149 	return m_pEdit->GetSelected().Len() != 0;
150 }
151 // -----------------------------------------------------------------------------
isPasteAllowed()152 sal_Bool OQueryTextView::isPasteAllowed()
153 {
154 	return sal_True;
155 }
156 // -----------------------------------------------------------------------------
isCopyAllowed()157 sal_Bool OQueryTextView::isCopyAllowed()
158 {
159 	return sal_True;
160 }
161 // -----------------------------------------------------------------------------
cut()162 void OQueryTextView::cut()
163 {
164 	if(!m_pEdit->IsInAccelAct() )
165 		m_pEdit->Cut();
166 	getContainerWindow()->getDesignView()->getController().setModified(sal_True);
167 }
168 // -----------------------------------------------------------------------------
paste()169 void OQueryTextView::paste()
170 {
171 	if(!m_pEdit->IsInAccelAct() )
172 		m_pEdit->Paste();
173 	getContainerWindow()->getDesignView()->getController().setModified(sal_True);
174 }
175 // -----------------------------------------------------------------------------
176