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 : :
21 : : #include "TableDesignControl.hxx"
22 : : #include "dbu_tbl.hrc"
23 : : #include "TableDesignView.hxx"
24 : : #include "TableController.hxx"
25 : : #include "browserids.hxx"
26 : : #include <com/sun/star/util/URL.hpp>
27 : : #include <com/sun/star/beans/PropertyValue.hpp>
28 : : #include "dbaccess_helpid.hrc"
29 : :
30 : : using namespace ::dbaui;
31 : : using namespace ::svt;
32 : : using namespace ::com::sun::star::uno;
33 : : using namespace ::com::sun::star::beans;
34 : : using namespace ::com::sun::star::util;
35 : : //--- Defines
36 : : #define HANDLE_ID 0
37 : :
38 : : DBG_NAME(OTableRowView)
39 : : //------------------------------------------------------------------------
40 : 0 : OTableRowView::OTableRowView(Window* pParent)
41 : : :EditBrowseBox(pParent, ModuleRes(RID_DB_TAB_EDITOR),EBBF_NONE,
42 : : BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
43 : : BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
44 : : ,m_nDataPos(-1)
45 : : ,m_nCurrentPos(-1)
46 : : ,m_nCurUndoActId(0)
47 : : ,m_bCurrentModified(sal_False)
48 : : ,m_bUpdatable(sal_False)
49 [ # # ]: 0 : ,m_bClipboardFilled(sal_False)
50 : : {
51 : : DBG_CTOR(OTableRowView,NULL);
52 : :
53 : 0 : }
54 : :
55 : : //------------------------------------------------------------------------
56 : 0 : OTableRowView::~OTableRowView()
57 : : {
58 : :
59 : : DBG_DTOR(OTableRowView,NULL);
60 [ # # ]: 0 : }
61 : :
62 : : //------------------------------------------------------------------------
63 : 0 : void OTableRowView::Init()
64 : : {
65 [ # # ]: 0 : EditBrowseBox::Init();
66 : :
67 [ # # ]: 0 : Font aFont( GetDataWindow().GetFont() );
68 [ # # ]: 0 : aFont.SetWeight( WEIGHT_NORMAL );
69 [ # # ]: 0 : GetDataWindow().SetFont( aFont );
70 : :
71 : : // Font fuer die Ueberschriften auf Light setzen
72 [ # # ]: 0 : aFont = GetFont();
73 [ # # ]: 0 : aFont.SetWeight( WEIGHT_LIGHT );
74 [ # # ]: 0 : SetFont(aFont);
75 : :
76 : : // HandleColumn, fuer maximal fuenf Ziffern einrichten
77 [ # # ][ # # ]: 0 : InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth(rtl::OUString('0')) * 4)/*, sal_True */);
[ # # ][ # # ]
78 : :
79 : : BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
80 : 0 : BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTOSIZE_LASTCOL;
81 [ # # ][ # # ]: 0 : if (IsUpdatable())
82 : 0 : nMode |= BROWSER_HIDECURSOR;
83 : :
84 [ # # ][ # # ]: 0 : SetMode(nMode);
85 : 0 : }
86 : :
87 : : //------------------------------------------------------------------------
88 : 0 : void OTableRowView::KeyInput( const KeyEvent& rEvt )
89 : : {
90 [ # # ]: 0 : if (IsDeleteAllowed(0))
91 : : {
92 [ # # # # : 0 : if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
# # ][ # # ]
93 : 0 : !rEvt.GetKeyCode().IsShift() &&
94 : 0 : !rEvt.GetKeyCode().IsMod1())
95 : : {
96 : 0 : DeleteRows();
97 : 0 : return;
98 : : }
99 [ # # ]: 0 : if( rEvt.GetKeyCode().GetCode() == KEY_F2 )
100 : : {
101 : 0 : ::com::sun::star::util::URL aUrl;
102 [ # # ]: 0 : aUrl.Complete =::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DSBEditDoc"));
103 [ # # ][ # # ]: 0 : GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
[ # # ][ # # ]
104 : : }
105 : : }
106 : 0 : EditBrowseBox::KeyInput(rEvt);
107 : : }
108 : :
109 : : //------------------------------------------------------------------------
110 : 0 : void OTableRowView::SetUpdatable( sal_Bool bUpdate )
111 : : {
112 : 0 : m_bUpdatable = bUpdate;
113 : :
114 : 0 : }
115 : :
116 : : //------------------------------------------------------------------------
117 : 0 : void OTableRowView::Command(const CommandEvent& rEvt)
118 : : {
119 : :
120 [ # # ]: 0 : switch (rEvt.GetCommand())
121 : : {
122 : : case COMMAND_CONTEXTMENU:
123 : : {
124 [ # # ]: 0 : if (!rEvt.IsMouseEvent())
125 : : {
126 : 0 : EditBrowseBox::Command(rEvt);
127 : 0 : return;
128 : : }
129 : :
130 : 0 : sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
131 : 0 : long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
132 : :
133 [ # # ]: 0 : if ( nColId == HANDLE_ID )
134 : : {
135 [ # # ][ # # ]: 0 : PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
136 [ # # ]: 0 : long nSelectRowCount = GetSelectRowCount();
137 [ # # ]: 0 : aContextMenu.EnableItem( SID_CUT, nSelectRowCount != 0);
138 [ # # ]: 0 : aContextMenu.EnableItem( SID_COPY, nSelectRowCount != 0);
139 [ # # ]: 0 : aContextMenu.EnableItem( SID_PASTE, m_bClipboardFilled );
140 [ # # ][ # # ]: 0 : aContextMenu.EnableItem( SID_DELETE, IsUpdatable() && nSelectRowCount != 0 );
[ # # ][ # # ]
141 [ # # ][ # # : 0 : switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
# # # # ]
142 : : {
143 : : case SID_CUT:
144 [ # # ]: 0 : cut();
145 : 0 : break;
146 : : case SID_COPY:
147 [ # # ]: 0 : copy();
148 : 0 : break;
149 : : case SID_PASTE:
150 [ # # ]: 0 : Paste( nRow );
151 [ # # ]: 0 : SetNoSelection();
152 [ # # ]: 0 : GoToRow( nRow );
153 [ # # ]: 0 : SeekRow( nRow );
154 : 0 : break;
155 : :
156 : : case SID_DELETE:
157 [ # # ]: 0 : DeleteRows();
158 : 0 : break;
159 : : case SID_TABLEDESIGN_INSERTROWS:
160 [ # # ]: 0 : InsertNewRows( nRow );
161 [ # # ]: 0 : SetNoSelection();
162 [ # # ]: 0 : GoToRow( nRow );
163 [ # # ]: 0 : SeekRow( nRow );
164 : 0 : break;
165 : : default:
166 : 0 : break;
167 [ # # ]: 0 : }
168 : : }
169 : :
170 : : }
171 : : default:
172 : 0 : EditBrowseBox::Command(rEvt);
173 : : }
174 : :
175 : : }
176 : :
177 : : //------------------------------------------------------------------------------
178 : 0 : void OTableRowView::cut()
179 : : {
180 : 0 : CopyRows();
181 : 0 : DeleteRows();
182 : 0 : }
183 : :
184 : : //------------------------------------------------------------------------------
185 : 0 : void OTableRowView::copy()
186 : : {
187 : 0 : CopyRows();
188 : 0 : }
189 : :
190 : : //------------------------------------------------------------------------------
191 : 0 : void OTableRowView::paste()
192 : : {
193 : : OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
194 : 0 : }
195 : :
196 : : //------------------------------------------------------------------------------
197 : 0 : void OTableRowView::Paste( long nRow )
198 : : {
199 : 0 : InsertRows( nRow );
200 : 0 : }
201 : :
202 : : //------------------------------------------------------------------------------
203 : 0 : EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
204 : : {
205 [ # # ][ # # ]: 0 : if (nRow >= 0 && m_nDataPos == nRow)
206 : 0 : return CURRENT;
207 : : else
208 : 0 : return CLEAN;
209 : : }
210 : :
211 : :
212 : :
213 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|