Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "QueryTextView.hxx"
21 : #include "querycontainerwindow.hxx"
22 : #include "QueryViewSwitch.hxx"
23 : #include "sqledit.hxx"
24 : #include "undosqledit.hxx"
25 : #include "browserids.hxx"
26 : #include "querycontroller.hxx"
27 : #include "dbu_qry.hrc"
28 : #include "dbustrings.hrc"
29 : #include <toolkit/helper/vclunohelper.hxx>
30 : #include <vcl/split.hxx>
31 : #include <vcl/svapp.hxx>
32 : #include <comphelper/types.hxx>
33 : #include "QueryDesignView.hxx"
34 : #include <boost/scoped_ptr.hpp>
35 :
36 : using namespace dbaui;
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::lang;
39 : using namespace ::com::sun::star::frame;
40 :
41 : // end of temp classes
42 0 : OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
43 0 : :Window(_pParent)
44 : {
45 0 : m_pEdit = new OSqlEdit(this);
46 0 : m_pEdit->SetRightToLeft(false);
47 0 : m_pEdit->ClearModifyFlag();
48 0 : m_pEdit->SaveValue();
49 0 : m_pEdit->SetPosPixel( Point( 0, 0 ) );
50 0 : m_pEdit->Show();
51 0 : }
52 :
53 0 : OQueryTextView::~OQueryTextView()
54 : {
55 0 : boost::scoped_ptr<Window> aTemp(m_pEdit);
56 0 : m_pEdit = NULL;
57 0 : }
58 :
59 0 : void OQueryTextView::GetFocus()
60 : {
61 0 : if ( m_pEdit )
62 0 : m_pEdit->GrabFocus();
63 0 : }
64 :
65 0 : void OQueryTextView::Resize()
66 : {
67 0 : Window::Resize();
68 0 : m_pEdit->SetSizePixel( GetOutputSizePixel() );
69 0 : }
70 :
71 : // check if the statement is correct when not returning false
72 0 : sal_Bool OQueryTextView::checkStatement()
73 : {
74 0 : return sal_True;
75 : }
76 :
77 0 : OUString OQueryTextView::getStatement()
78 : {
79 0 : return m_pEdit->GetText();
80 : }
81 :
82 0 : void OQueryTextView::setReadOnly(sal_Bool _bReadOnly)
83 : {
84 0 : m_pEdit->SetReadOnly(_bReadOnly);
85 0 : }
86 :
87 0 : void OQueryTextView::clear()
88 : {
89 0 : OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
90 :
91 0 : pUndoAct->SetOriginalText( m_pEdit->GetText() );
92 0 : getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
93 :
94 0 : m_pEdit->SetText(OUString());
95 0 : }
96 :
97 0 : void OQueryTextView::setStatement(const OUString& _rsStatement)
98 : {
99 0 : m_pEdit->SetText(_rsStatement);
100 0 : }
101 :
102 0 : void OQueryTextView::copy()
103 : {
104 0 : if(!m_pEdit->IsInAccelAct() )
105 0 : m_pEdit->Copy();
106 0 : }
107 :
108 0 : sal_Bool OQueryTextView::isCutAllowed()
109 : {
110 0 : return !m_pEdit->GetSelected().isEmpty();
111 : }
112 :
113 0 : sal_Bool OQueryTextView::isPasteAllowed()
114 : {
115 0 : return sal_True;
116 : }
117 :
118 0 : sal_Bool OQueryTextView::isCopyAllowed()
119 : {
120 0 : return sal_True;
121 : }
122 :
123 0 : void OQueryTextView::cut()
124 : {
125 0 : if(!m_pEdit->IsInAccelAct() )
126 0 : m_pEdit->Cut();
127 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
128 0 : }
129 :
130 0 : void OQueryTextView::paste()
131 : {
132 0 : if(!m_pEdit->IsInAccelAct() )
133 0 : m_pEdit->Paste();
134 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
135 0 : }
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|