1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: QueryTextView.cxx,v $
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"
36 #ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
37 #include "querycontainerwindow.hxx"
39 #ifndef DBAUI_QUERYVIEWSWITCH_HXX
40 #include "QueryViewSwitch.hxx"
42 #ifndef DBAUI_SQLEDIT_HXX
43 #include "sqledit.hxx"
45 #ifndef DBAUI_UNDOSQLEDIT_HXX
46 #include "undosqledit.hxx"
48 #ifndef DBACCESS_UI_BROWSER_ID_HXX
49 #include "browserids.hxx"
51 #ifndef DBAUI_QUERYCONTROLLER_HXX
52 #include "querycontroller.hxx"
55 #include "dbu_qry.hrc"
57 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
58 #include "dbustrings.hrc"
60 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
61 #include <toolkit/unohlp.hxx>
64 #include <vcl/split.hxx>
67 #include <vcl/svapp.hxx>
69 #ifndef _COMPHELPER_TYPES_HXX_
70 #include <comphelper/types.hxx>
72 #ifndef DBAUI_QUERYDESIGNVIEW_HXX
73 #include "QueryDesignView.hxx"
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
)
88 DBG_CTOR(OQueryTextView
,NULL
);
89 m_pEdit
= new OSqlEdit(this);
90 m_pEdit
->SetRightToLeft(FALSE
);
91 m_pEdit
->ClearModifyFlag();
93 m_pEdit
->SetPosPixel( Point( 0, 0 ) );
95 // m_pEdit->GrabFocus();
97 // -----------------------------------------------------------------------------
98 OQueryTextView::~OQueryTextView()
100 DBG_DTOR(OQueryTextView
,NULL
);
101 ::std::auto_ptr
<Window
> aTemp(m_pEdit
);
104 // -----------------------------------------------------------------------------
105 void OQueryTextView::GetFocus()
108 m_pEdit
->GrabFocus();
110 // -------------------------------------------------------------------------
111 void OQueryTextView::Resize()
114 m_pEdit
->SetSizePixel( GetOutputSizePixel() );
116 // -----------------------------------------------------------------------------
117 // check if the statement is correct when not returning false
118 sal_Bool
OQueryTextView::checkStatement()
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() )
153 // -----------------------------------------------------------------------------
154 sal_Bool
OQueryTextView::isCutAllowed()
156 return m_pEdit
->GetSelected().Len() != 0;
158 // -----------------------------------------------------------------------------
159 sal_Bool
OQueryTextView::isPasteAllowed()
163 // -----------------------------------------------------------------------------
164 sal_Bool
OQueryTextView::isCopyAllowed()
168 // -----------------------------------------------------------------------------
169 void OQueryTextView::cut()
171 if(!m_pEdit
->IsInAccelAct() )
173 getContainerWindow()->getDesignView()->getController().setModified(sal_True
);
175 // -----------------------------------------------------------------------------
176 void OQueryTextView::paste()
178 if(!m_pEdit
->IsInAccelAct() )
180 getContainerWindow()->getDesignView()->getController().setModified(sal_True
);
182 // -----------------------------------------------------------------------------