Update ooo320-m1
[ooovba.git] / svtools / source / table / defaultinputhandler.cxx
blobc25eabb68f841a4ed28504269a2148eb79a4cdc9
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2009 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
26 // MARKER(update_precomp.py): autogen include statement, do not remove
27 #include "precompiled_svtools.hxx"
29 #include "svtools/table/defaultinputhandler.hxx"
30 #include "svtools/table/abstracttablecontrol.hxx"
32 #include <tools/debug.hxx>
33 #include <vcl/event.hxx>
34 #include <vcl/cursor.hxx>
35 #include "svtools/table/tabledatawindow.hxx"
37 //........................................................................
38 namespace svt { namespace table
40 //.......................................................................
42 struct DefaultInputHandler_Impl
46 //====================================================================
47 //= DefaultInputHandler
48 //====================================================================
49 //--------------------------------------------------------------------
50 DefaultInputHandler::DefaultInputHandler()
51 :m_pImpl( new DefaultInputHandler_Impl )
55 //--------------------------------------------------------------------
56 DefaultInputHandler::~DefaultInputHandler()
58 DELETEZ( m_pImpl );
61 //--------------------------------------------------------------------
62 bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
64 (void)_rControl;
65 (void)_rMEvt;
66 return false;
69 //--------------------------------------------------------------------
70 bool DefaultInputHandler::MouseButtonDown( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
72 bool bHandled = false;
73 Point aPoint = _rMEvt.GetPosPixel();
74 if(_rControl.isClickInVisibleArea(aPoint))
76 if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
78 LoseFocus(_rControl);
79 _rControl.setCursorAtCurrentCell(aPoint);
80 bHandled = true;
82 else
84 bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt);
87 return bHandled;
90 //--------------------------------------------------------------------
91 bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
93 bool bHandled = false;
94 Point aPoint = _rMEvt.GetPosPixel();
95 if(_rControl.isClickInVisibleArea(aPoint))
97 if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
99 GetFocus(_rControl);
100 _rControl.setCursorAtCurrentCell(aPoint);
101 bHandled = true;
103 else
104 bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt);
106 return bHandled;
109 //--------------------------------------------------------------------
110 bool DefaultInputHandler::KeyInput( IAbstractTableControl& _rControl, const KeyEvent& rKEvt )
112 bool bHandled = false;
114 const KeyCode& rKeyCode = rKEvt.GetKeyCode();
115 USHORT nKeyCode = rKeyCode.GetCode();
117 struct _ActionMapEntry
119 USHORT nKeyCode;
120 USHORT nKeyModifier;
121 TableControlAction eAction;
123 static aKnownActions[] = {
124 { KEY_DOWN, 0, cursorDown },
125 { KEY_UP, 0, cursorUp },
126 { KEY_LEFT, 0, cursorLeft },
127 { KEY_RIGHT, 0, cursorRight },
128 { KEY_HOME, 0, cursorToLineStart },
129 { KEY_END, 0, cursorToLineEnd },
130 { KEY_PAGEUP, 0, cursorPageUp },
131 { KEY_PAGEDOWN, 0, cursorPageDown },
132 { KEY_PAGEUP, KEY_MOD1, cursorToFirstLine },
133 { KEY_PAGEDOWN, KEY_MOD1, cursorToLastLine },
134 { KEY_HOME, KEY_MOD1, cursorTopLeft },
135 { KEY_END, KEY_MOD1, cursorBottomRight },
136 { KEY_SPACE, KEY_MOD1, cursorSelectRow },
137 { KEY_UP, KEY_SHIFT, cursorSelectRowUp },
138 { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown },
139 { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom },
140 { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop },
142 { 0, 0, invalidTableControlAction }
145 const _ActionMapEntry* pActions = aKnownActions;
146 for ( ; pActions->eAction != invalidTableControlAction; ++pActions )
148 if ( ( pActions->nKeyCode == nKeyCode ) && ( pActions->nKeyModifier == rKeyCode.GetAllModifier() ) )
150 bHandled = _rControl.dispatchAction( pActions->eAction );
151 break;
155 return bHandled;
158 //--------------------------------------------------------------------
159 bool DefaultInputHandler::GetFocus( IAbstractTableControl& _rControl )
161 _rControl.showCursor();
162 return false; // continue processing
165 //--------------------------------------------------------------------
166 bool DefaultInputHandler::LoseFocus( IAbstractTableControl& _rControl )
168 _rControl.hideCursor();
169 return false; // continue processing
172 //--------------------------------------------------------------------
173 bool DefaultInputHandler::RequestHelp( IAbstractTableControl& _rControl, const HelpEvent& _rHEvt )
175 (void)_rControl;
176 (void)_rHEvt;
177 // TODO
178 return false;
181 //--------------------------------------------------------------------
182 bool DefaultInputHandler::Command( IAbstractTableControl& _rControl, const CommandEvent& _rCEvt )
184 (void)_rControl;
185 (void)_rCEvt;
186 // TODO
187 return false;
190 //--------------------------------------------------------------------
191 bool DefaultInputHandler::PreNotify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt )
193 (void)_rControl;
194 (void)_rNEvt;
195 // TODO
196 return false;
199 //--------------------------------------------------------------------
200 bool DefaultInputHandler::Notify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt )
202 (void)_rControl;
203 (void)_rNEvt;
204 // TODO
205 return false;
208 //........................................................................
209 } } // namespace svt::table
210 //........................................................................