Branch data 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/unohlp.hxx>
30 : : #include <vcl/split.hxx>
31 : : #include <vcl/svapp.hxx>
32 : : #include <comphelper/types.hxx>
33 : : #include "QueryDesignView.hxx"
34 : :
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;
39 : : // -----------------------------------------------------------------------------
40 : :
41 : : // end of temp classes
42 : : // -------------------------------------------------------------------------
43 : : DBG_NAME(OQueryTextView)
44 : 0 : OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
45 : 0 : :Window(_pParent)
46 : : {
47 : : DBG_CTOR(OQueryTextView,NULL);
48 [ # # ][ # # ]: 0 : m_pEdit = new OSqlEdit(this);
49 [ # # ]: 0 : m_pEdit->SetRightToLeft(sal_False);
50 [ # # ]: 0 : m_pEdit->ClearModifyFlag();
51 [ # # ]: 0 : m_pEdit->SaveValue();
52 [ # # ]: 0 : m_pEdit->SetPosPixel( Point( 0, 0 ) );
53 [ # # ]: 0 : m_pEdit->Show();
54 : 0 : }
55 : : // -----------------------------------------------------------------------------
56 : 0 : OQueryTextView::~OQueryTextView()
57 : : {
58 : : DBG_DTOR(OQueryTextView,NULL);
59 : 0 : ::std::auto_ptr<Window> aTemp(m_pEdit);
60 [ # # ]: 0 : m_pEdit = NULL;
61 [ # # ]: 0 : }
62 : : // -----------------------------------------------------------------------------
63 : 0 : void OQueryTextView::GetFocus()
64 : : {
65 [ # # ]: 0 : if ( m_pEdit )
66 : 0 : m_pEdit->GrabFocus();
67 : 0 : }
68 : : // -------------------------------------------------------------------------
69 : 0 : void OQueryTextView::Resize()
70 : : {
71 : 0 : Window::Resize();
72 [ # # ]: 0 : m_pEdit->SetSizePixel( GetOutputSizePixel() );
73 : 0 : }
74 : : // -----------------------------------------------------------------------------
75 : : // check if the statement is correct when not returning false
76 : 0 : sal_Bool OQueryTextView::checkStatement()
77 : : {
78 : 0 : return sal_True;
79 : : }
80 : : // -----------------------------------------------------------------------------
81 : 0 : ::rtl::OUString OQueryTextView::getStatement()
82 : : {
83 [ # # ]: 0 : return m_pEdit->GetText();
84 : : }
85 : : // -----------------------------------------------------------------------------
86 : 0 : void OQueryTextView::setReadOnly(sal_Bool _bReadOnly)
87 : : {
88 : 0 : m_pEdit->SetReadOnly(_bReadOnly);
89 : 0 : }
90 : : // -----------------------------------------------------------------------------
91 : 0 : void OQueryTextView::clear()
92 : : {
93 [ # # ]: 0 : OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
94 : :
95 [ # # ]: 0 : pUndoAct->SetOriginalText( m_pEdit->GetText() );
96 : 0 : getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
97 : :
98 [ # # ]: 0 : m_pEdit->SetText(String());
99 : 0 : }
100 : : // -----------------------------------------------------------------------------
101 : 0 : void OQueryTextView::setStatement(const ::rtl::OUString& _rsStatement)
102 : : {
103 [ # # ]: 0 : m_pEdit->SetText(_rsStatement);
104 : 0 : }
105 : : // -----------------------------------------------------------------------------
106 : 0 : void OQueryTextView::copy()
107 : : {
108 [ # # ]: 0 : if(!m_pEdit->IsInAccelAct() )
109 : 0 : m_pEdit->Copy();
110 : 0 : }
111 : : // -----------------------------------------------------------------------------
112 : 0 : sal_Bool OQueryTextView::isCutAllowed()
113 : : {
114 : 0 : return m_pEdit->GetSelected().Len() != 0;
115 : : }
116 : : // -----------------------------------------------------------------------------
117 : 0 : sal_Bool OQueryTextView::isPasteAllowed()
118 : : {
119 : 0 : return sal_True;
120 : : }
121 : : // -----------------------------------------------------------------------------
122 : 0 : sal_Bool OQueryTextView::isCopyAllowed()
123 : : {
124 : 0 : return sal_True;
125 : : }
126 : : // -----------------------------------------------------------------------------
127 : 0 : void OQueryTextView::cut()
128 : : {
129 [ # # ]: 0 : if(!m_pEdit->IsInAccelAct() )
130 : 0 : m_pEdit->Cut();
131 : 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
132 : 0 : }
133 : : // -----------------------------------------------------------------------------
134 : 0 : void OQueryTextView::paste()
135 : : {
136 [ # # ]: 0 : if(!m_pEdit->IsInAccelAct() )
137 : 0 : m_pEdit->Paste();
138 : 0 : getContainerWindow()->getDesignView()->getController().setModified(sal_True);
139 : 0 : }
140 : : // -----------------------------------------------------------------------------
141 : :
142 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|