Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / ui / querydesign / QueryTextView.cxx
blob6090b28014a3749755ed99d0c34e15cb850817e9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
35 using namespace dbaui;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::frame;
40 // end of temp classes
41 OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
42 :Window(_pParent)
44 m_pEdit = VclPtr<OSqlEdit>::Create(this);
45 m_pEdit->SetRightToLeft(false);
46 m_pEdit->ClearModifyFlag();
47 m_pEdit->SaveValue();
48 m_pEdit->SetPosPixel( Point( 0, 0 ) );
49 m_pEdit->Show();
52 OQueryTextView::~OQueryTextView()
54 disposeOnce();
57 void OQueryTextView::dispose()
59 m_pEdit.disposeAndClear();
60 vcl::Window::dispose();
63 void OQueryTextView::GetFocus()
65 if ( m_pEdit )
66 m_pEdit->GrabFocus();
69 void OQueryTextView::Resize()
71 Window::Resize();
72 m_pEdit->SetSizePixel( GetOutputSizePixel() );
75 OUString OQueryTextView::getStatement()
77 return m_pEdit->GetText();
80 void OQueryTextView::clear()
82 OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
84 pUndoAct->SetOriginalText( m_pEdit->GetText() );
85 getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
87 m_pEdit->SetText(OUString());
90 void OQueryTextView::setStatement(const OUString& _rsStatement)
92 m_pEdit->SetText(_rsStatement);
95 void OQueryTextView::copy()
97 if(!m_pEdit->IsInAccelAct() )
98 m_pEdit->Copy();
101 bool OQueryTextView::isCutAllowed()
103 return !m_pEdit->GetSelected().isEmpty();
106 void OQueryTextView::cut()
108 if(!m_pEdit->IsInAccelAct() )
109 m_pEdit->Cut();
110 getContainerWindow()->getDesignView()->getController().setModified(true);
113 void OQueryTextView::paste()
115 if(!m_pEdit->IsInAccelAct() )
116 m_pEdit->Paste();
117 getContainerWindow()->getDesignView()->getController().setModified(true);
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */