LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/table - defaultinputhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 64 0.0 %
Date: 2012-12-27 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          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 "svtools/table/defaultinputhandler.hxx"
      22             : #include "svtools/table/tablecontrolinterface.hxx"
      23             : 
      24             : #include "tabledatawindow.hxx"
      25             : #include "mousefunction.hxx"
      26             : 
      27             : #include <vcl/event.hxx>
      28             : #include <vcl/cursor.hxx>
      29             : 
      30             : //......................................................................................................................
      31             : namespace svt { namespace table
      32             : {
      33             : //......................................................................................................................
      34             : 
      35             :     typedef ::rtl::Reference< IMouseFunction >  PMouseFunction;
      36             :     typedef ::std::vector< PMouseFunction >     MouseFunctions;
      37           0 :     struct DefaultInputHandler_Impl
      38             :     {
      39             :         PMouseFunction  pActiveFunction;
      40             :         MouseFunctions  aMouseFunctions;
      41             :     };
      42             : 
      43             :     //==================================================================================================================
      44             :     //= DefaultInputHandler
      45             :     //==================================================================================================================
      46             :     //------------------------------------------------------------------------------------------------------------------
      47           0 :     DefaultInputHandler::DefaultInputHandler()
      48           0 :         :m_pImpl( new DefaultInputHandler_Impl )
      49             :     {
      50           0 :         m_pImpl->aMouseFunctions.push_back( new ColumnResize );
      51           0 :         m_pImpl->aMouseFunctions.push_back( new RowSelection );
      52           0 :         m_pImpl->aMouseFunctions.push_back( new ColumnSortHandler );
      53           0 :     }
      54             : 
      55             :     //------------------------------------------------------------------------------------------------------------------
      56           0 :     DefaultInputHandler::~DefaultInputHandler()
      57             :     {
      58           0 :     }
      59             : 
      60             :     //------------------------------------------------------------------------------------------------------------------
      61             :     namespace
      62             :     {
      63           0 :         bool lcl_delegateMouseEvent( DefaultInputHandler_Impl& i_impl, ITableControl& i_control, const MouseEvent& i_event,
      64             :             FunctionResult ( IMouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) )
      65             :         {
      66           0 :             if ( i_impl.pActiveFunction.is() )
      67             :             {
      68           0 :                 bool furtherHandler = false;
      69           0 :                 switch ( (i_impl.pActiveFunction.get()->*i_handlerMethod)( i_control, i_event ) )
      70             :                 {
      71             :                 case ActivateFunction:
      72             :                     OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected - function already *is* active!" );
      73           0 :                     break;
      74             :                 case ContinueFunction:
      75           0 :                     break;
      76             :                 case DeactivateFunction:
      77           0 :                     i_impl.pActiveFunction.clear();
      78           0 :                     break;
      79             :                 case SkipFunction:
      80           0 :                     furtherHandler = true;
      81           0 :                     break;
      82             :                 }
      83           0 :                 if ( !furtherHandler )
      84             :                     // handled the event
      85           0 :                     return true;
      86             :             }
      87             : 
      88             :             // ask all other handlers
      89           0 :             bool handled = false;
      90           0 :             for (   MouseFunctions::iterator handler = i_impl.aMouseFunctions.begin();
      91           0 :                     ( handler != i_impl.aMouseFunctions.end() ) && !handled;
      92             :                     ++handler
      93             :                 )
      94             :             {
      95           0 :                 if ( *handler == i_impl.pActiveFunction )
      96             :                     // we already invoked this function
      97           0 :                     continue;
      98             : 
      99           0 :                 switch ( (handler->get()->*i_handlerMethod)( i_control, i_event ) )
     100             :                 {
     101             :                 case ActivateFunction:
     102           0 :                     i_impl.pActiveFunction = *handler;
     103           0 :                     handled = true;
     104           0 :                     break;
     105             :                 case ContinueFunction:
     106             :                 case DeactivateFunction:
     107             :                     OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected: inactivate handler cannot be continued or deactivated!" );
     108           0 :                     break;
     109             :                 case SkipFunction:
     110           0 :                     handled = false;
     111           0 :                     break;
     112             :                 }
     113             :             }
     114           0 :             return handled;
     115             :         }
     116             :     }
     117             : 
     118             :     //------------------------------------------------------------------------------------------------------------------
     119           0 :     bool DefaultInputHandler::MouseMove( ITableControl& i_tableControl, const MouseEvent& i_event )
     120             :     {
     121           0 :         return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseMove );
     122             :     }
     123             : 
     124             :     //------------------------------------------------------------------------------------------------------------------
     125           0 :     bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event )
     126             :     {
     127           0 :         return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown );
     128             :     }
     129             : 
     130             :     //------------------------------------------------------------------------------------------------------------------
     131           0 :     bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event )
     132             :     {
     133           0 :         return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp );
     134             :     }
     135             : 
     136             :     //------------------------------------------------------------------------------------------------------------------
     137           0 :     bool DefaultInputHandler::KeyInput( ITableControl& _rControl, const KeyEvent& rKEvt )
     138             :     {
     139           0 :         bool bHandled = false;
     140             : 
     141           0 :         const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     142           0 :         sal_uInt16 nKeyCode = rKeyCode.GetCode();
     143             : 
     144             :         struct _ActionMapEntry
     145             :         {
     146             :             sal_uInt16              nKeyCode;
     147             :             sal_uInt16              nKeyModifier;
     148             :             TableControlAction  eAction;
     149             :         }
     150             :         static aKnownActions[] = {
     151             :             { KEY_DOWN,     0,          cursorDown },
     152             :             { KEY_UP,       0,          cursorUp },
     153             :             { KEY_LEFT,     0,          cursorLeft },
     154             :             { KEY_RIGHT,    0,          cursorRight },
     155             :             { KEY_HOME,     0,          cursorToLineStart },
     156             :             { KEY_END,      0,          cursorToLineEnd },
     157             :             { KEY_PAGEUP,   0,          cursorPageUp },
     158             :             { KEY_PAGEDOWN, 0,          cursorPageDown },
     159             :             { KEY_PAGEUP,   KEY_MOD1,   cursorToFirstLine },
     160             :             { KEY_PAGEDOWN, KEY_MOD1,   cursorToLastLine },
     161             :             { KEY_HOME,     KEY_MOD1,   cursorTopLeft },
     162             :             { KEY_END,      KEY_MOD1,   cursorBottomRight },
     163             :             { KEY_SPACE,    KEY_MOD1,   cursorSelectRow },
     164             :             { KEY_UP,       KEY_SHIFT,  cursorSelectRowUp },
     165             :             { KEY_DOWN,     KEY_SHIFT,  cursorSelectRowDown },
     166             :             { KEY_END,      KEY_SHIFT,  cursorSelectRowAreaBottom },
     167             :             { KEY_HOME,     KEY_SHIFT,  cursorSelectRowAreaTop },
     168             : 
     169             :             { 0, 0, invalidTableControlAction }
     170             :         };
     171             : 
     172           0 :         const _ActionMapEntry* pActions = aKnownActions;
     173           0 :         for ( ; pActions->eAction != invalidTableControlAction; ++pActions )
     174             :         {
     175           0 :             if ( ( pActions->nKeyCode == nKeyCode ) && ( pActions->nKeyModifier == rKeyCode.GetAllModifier() ) )
     176             :             {
     177           0 :                 bHandled = _rControl.dispatchAction( pActions->eAction );
     178           0 :                 break;
     179             :             }
     180             :         }
     181             : 
     182           0 :         return bHandled;
     183             :     }
     184             : 
     185             :     //------------------------------------------------------------------------------------------------------------------
     186           0 :     bool DefaultInputHandler::GetFocus( ITableControl& _rControl )
     187             :     {
     188           0 :         _rControl.showCursor();
     189           0 :         return false;   // continue processing
     190             :     }
     191             : 
     192             :     //------------------------------------------------------------------------------------------------------------------
     193           0 :     bool DefaultInputHandler::LoseFocus( ITableControl& _rControl )
     194             :     {
     195           0 :         _rControl.hideCursor();
     196           0 :         return false;   // continue processing
     197             :     }
     198             : 
     199             :     //------------------------------------------------------------------------------------------------------------------
     200           0 :     bool DefaultInputHandler::RequestHelp( ITableControl& _rControl, const HelpEvent& _rHEvt )
     201             :     {
     202             :         (void)_rControl;
     203             :         (void)_rHEvt;
     204             :         // TODO
     205           0 :         return false;
     206             :     }
     207             : 
     208             :     //------------------------------------------------------------------------------------------------------------------
     209           0 :     bool DefaultInputHandler::Command( ITableControl& _rControl, const CommandEvent& _rCEvt )
     210             :     {
     211             :         (void)_rControl;
     212             :         (void)_rCEvt;
     213             :         // TODO
     214           0 :         return false;
     215             :     }
     216             : 
     217             :     //------------------------------------------------------------------------------------------------------------------
     218           0 :     bool DefaultInputHandler::PreNotify( ITableControl& _rControl, NotifyEvent& _rNEvt )
     219             :     {
     220             :         (void)_rControl;
     221             :         (void)_rNEvt;
     222             :         // TODO
     223           0 :         return false;
     224             :     }
     225             : 
     226             :     //------------------------------------------------------------------------------------------------------------------
     227           0 :     bool DefaultInputHandler::Notify( ITableControl& _rControl, NotifyEvent& _rNEvt )
     228             :     {
     229             :         (void)_rControl;
     230             :         (void)_rNEvt;
     231             :         // TODO
     232           0 :         return false;
     233             :     }
     234             : //......................................................................................................................
     235             : } } // namespace svt::table
     236             : //......................................................................................................................
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10