LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/window - keycod.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 39 10.3 %
Date: 2012-12-27 Functions: 1 5 20.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 <salinst.hxx>
      22             : #include <salframe.hxx>
      23             : #include <svdata.hxx>
      24             : 
      25             : #include <vcl/window.hxx>
      26             : #include <vcl/keycod.hxx>
      27             : 
      28             : #include <tools/rc.h>
      29             : 
      30             : 
      31             : // =======================================================================
      32             : static sal_uInt16 aImplKeyFuncTab[(KEYFUNC_FRONT+1)*4] =
      33             : {
      34             :     0, 0, 0, 0,                                                    // KEYFUNC_DONTKNOW
      35             :     KEY_N | KEY_MOD1, 0, 0, 0,                                     // KEYFUNC_NEW
      36             :     KEY_O | KEY_MOD1, KEY_OPEN, 0, 0,                              // KEYFUNC_OPEN
      37             :     KEY_S | KEY_MOD1, 0, 0, 0,                                     // KEYFUNC_SAVE
      38             :     KEY_S | KEY_SHIFT | KEY_MOD1, 0, 0, 0,                         // KEYFUNC_SAVEAS
      39             :     KEY_P | KEY_MOD1, 0, 0, 0,                                     // KEYFUNC_PRINT
      40             :     KEY_W | KEY_MOD1, KEY_F4 | KEY_MOD1, 0, 0,                     // KEYFUNC_CLOSE
      41             :     KEY_Q | KEY_MOD1, KEY_F4 | KEY_MOD2, 0, 0,                     // KEYFUNC_QUIT
      42             :     KEY_X | KEY_MOD1, KEY_DELETE | KEY_SHIFT, KEY_CUT, 0,          // KEYFUNC_CUT
      43             :     KEY_C | KEY_MOD1, KEY_INSERT | KEY_MOD1, KEY_COPY, 0,          // KEYFUNC_COPY
      44             :     KEY_V | KEY_MOD1, KEY_INSERT | KEY_SHIFT, KEY_PASTE, 0,        // KEYFUNC_PASTE
      45             :     KEY_Z | KEY_MOD1, KEY_BACKSPACE | KEY_MOD2, KEY_UNDO, 0,       // KEYFUNC_UNDO
      46             :     KEY_Y | KEY_MOD1, KEY_UNDO | KEY_SHIFT, 0, 0,                  // KEYFUNC_REDO
      47             :     KEY_DELETE, 0, 0, 0,                                           // KEYFUNC_DELETE
      48             :     KEY_REPEAT, 0, 0, 0,                                           // KEYFUNC_REPEAT
      49             :     KEY_F | KEY_MOD1, KEY_FIND, 0, 0,                              // KEYFUNC_FIND
      50             :     KEY_F | KEY_SHIFT | KEY_MOD1, KEY_SHIFT | KEY_FIND, 0, 0,      // KEYFUNC_FINDBACKWARD
      51             :     KEY_RETURN | KEY_MOD2, 0, 0, 0,                                // KEYFUNC_PROPERTIES
      52             :     0, 0, 0, 0                                                     // KEYFUNC_FRONT
      53             : };
      54             : 
      55             : // -----------------------------------------------------------------------
      56             : 
      57           0 : void ImplGetKeyCode( KeyFuncType eFunc, sal_uInt16& rCode1, sal_uInt16& rCode2, sal_uInt16& rCode3, sal_uInt16& rCode4 )
      58             : {
      59           0 :     sal_uInt16 nIndex = (sal_uInt16)eFunc;
      60           0 :     nIndex *= 4;
      61           0 :     rCode1 = aImplKeyFuncTab[nIndex];
      62           0 :     rCode2 = aImplKeyFuncTab[nIndex+1];
      63           0 :     rCode3 = aImplKeyFuncTab[nIndex+2];
      64           0 :         rCode4 = aImplKeyFuncTab[nIndex+3];
      65           0 : }
      66             : 
      67             : // =======================================================================
      68             : 
      69           0 : KeyCode::KeyCode( KeyFuncType eFunction )
      70             : {
      71             :     sal_uInt16 nDummy;
      72           0 :     ImplGetKeyCode( eFunction, nCode, nDummy, nDummy, nDummy );
      73           0 :     eFunc = eFunction;
      74           0 : }
      75             : 
      76             : // -----------------------------------------------------------------------
      77             : 
      78           0 : KeyCode::KeyCode( const ResId& rResId )
      79             : {
      80           0 :     rResId.SetRT( RSC_KEYCODE );
      81             : 
      82           0 :     ResMgr* pResMgr = rResId.GetResMgr();
      83           0 :     if ( pResMgr && pResMgr->GetResource( rResId ) )
      84             :     {
      85           0 :         pResMgr->Increment( sizeof( RSHEADER_TYPE ) );
      86             : 
      87           0 :         sal_uLong nKeyCode  = pResMgr->ReadLong();
      88           0 :         sal_uLong nModifier = pResMgr->ReadLong();
      89           0 :         sal_uLong nKeyFunc  = pResMgr->ReadLong();
      90             : 
      91           0 :         eFunc = (KeyFuncType)nKeyFunc;
      92           0 :         if ( eFunc != KEYFUNC_DONTKNOW )
      93             :         {
      94             :             sal_uInt16 nDummy;
      95           0 :             ImplGetKeyCode( eFunc, nCode, nDummy, nDummy, nDummy );
      96             :         }
      97             :         else
      98           0 :             nCode = sal::static_int_cast<sal_uInt16>(nKeyCode | nModifier);
      99             :     }
     100           0 : }
     101             : 
     102             : // -----------------------------------------------------------------------
     103             : 
     104          22 : XubString KeyCode::GetName( Window* pWindow ) const
     105             : {
     106          22 :     if ( !pWindow )
     107          22 :         pWindow = ImplGetDefaultWindow();
     108          22 :     return pWindow ? XubString( pWindow->ImplGetFrame()->GetKeyName( GetFullCode() ) ) : XubString();
     109             : }
     110             : 
     111             : // -----------------------------------------------------------------------
     112             : 
     113           0 : KeyFuncType KeyCode::GetFunction() const
     114             : {
     115           0 :     if ( eFunc != KEYFUNC_DONTKNOW )
     116           0 :         return eFunc;
     117             : 
     118           0 :     sal_uInt16 nCompCode = GetModifier() | GetCode();
     119           0 :     if ( nCompCode )
     120             :     {
     121           0 :         for ( sal_uInt16 i = (sal_uInt16)KEYFUNC_NEW; i < (sal_uInt16)KEYFUNC_FRONT; i++ )
     122             :         {
     123             :             sal_uInt16 nKeyCode1;
     124             :             sal_uInt16 nKeyCode2;
     125             :             sal_uInt16 nKeyCode3;
     126             :                         sal_uInt16 nKeyCode4;
     127           0 :             ImplGetKeyCode( (KeyFuncType)i, nKeyCode1, nKeyCode2, nKeyCode3, nKeyCode4 );
     128           0 :             if ( (nCompCode == nKeyCode1) || (nCompCode == nKeyCode2) || (nCompCode == nKeyCode3) || (nCompCode == nKeyCode4) )
     129           0 :                 return (KeyFuncType)i;
     130             :         }
     131             :     }
     132             : 
     133           0 :     return KEYFUNC_DONTKNOW;
     134             : }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10