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 = VclPtr<OSqlEdit>::Create(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 : disposeOnce();
56 0 : }
57 :
58 0 : void OQueryTextView::dispose()
59 : {
60 0 : m_pEdit.disposeAndClear();
61 0 : vcl::Window::dispose();
62 0 : }
63 :
64 0 : void OQueryTextView::GetFocus()
65 : {
66 0 : if ( m_pEdit )
67 0 : m_pEdit->GrabFocus();
68 0 : }
69 :
70 0 : void OQueryTextView::Resize()
71 : {
72 0 : Window::Resize();
73 0 : m_pEdit->SetSizePixel( GetOutputSizePixel() );
74 0 : }
75 :
76 0 : OUString OQueryTextView::getStatement()
77 : {
78 0 : return m_pEdit->GetText();
79 : }
80 :
81 0 : void OQueryTextView::clear()
82 : {
83 0 : OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
84 :
85 0 : pUndoAct->SetOriginalText( m_pEdit->GetText() );
86 0 : getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
87 :
88 0 : m_pEdit->SetText(OUString());
89 0 : }
90 :
91 0 : void OQueryTextView::setStatement(const OUString& _rsStatement)
92 : {
93 0 : m_pEdit->SetText(_rsStatement);
94 0 : }
95 :
96 0 : void OQueryTextView::copy()
97 : {
98 0 : if(!m_pEdit->IsInAccelAct() )
99 0 : m_pEdit->Copy();
100 0 : }
101 :
102 0 : bool OQueryTextView::isCutAllowed()
103 : {
104 0 : return !m_pEdit->GetSelected().isEmpty();
105 : }
106 :
107 0 : void OQueryTextView::cut()
108 : {
109 0 : if(!m_pEdit->IsInAccelAct() )
110 0 : m_pEdit->Cut();
111 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
112 0 : }
113 :
114 0 : void OQueryTextView::paste()
115 : {
116 0 : if(!m_pEdit->IsInAccelAct() )
117 0 : m_pEdit->Paste();
118 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
119 36 : }
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|