LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/vcl - keycod.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 52 21.2 %
Date: 2012-12-27 Functions: 6 19 31.6 %
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             : #ifndef _SV_KEYCODE_HXX
      21             : #define _SV_KEYCODE_HXX
      22             : 
      23             : #include <tools/string.hxx>
      24             : #include <tools/solar.h>
      25             : #include <vcl/dllapi.h>
      26             : #include <tools/resid.hxx>
      27             : #include <vcl/keycodes.hxx>
      28             : 
      29             : #include <vcl/vclenum.hxx>
      30             : 
      31             : class Window;
      32             : 
      33             : // -----------
      34             : // - KeyCode -
      35             : // -----------
      36             : 
      37             : class VCL_DLLPUBLIC KeyCode
      38             : {
      39             : private:
      40             :     sal_uInt16      nCode;
      41             :     KeyFuncType eFunc;
      42             : 
      43             : public:
      44         365 :                 KeyCode() { nCode = 0; eFunc = KEYFUNC_DONTKNOW; }
      45             :                 KeyCode( const ResId& rResId );
      46          44 :                 KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 )
      47          44 :                     { nCode = nKey | nModifier; eFunc = KEYFUNC_DONTKNOW; }
      48             :                 KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 );
      49             :                 KeyCode( KeyFuncType eFunction );
      50             : 
      51          22 :     sal_uInt16      GetFullCode() const { return nCode; }
      52          22 :     sal_uInt16      GetFullKeyCode() const { return (nCode) ; }
      53           0 :     KeyFuncType GetFullFunction() const { return eFunc; }
      54             :     sal_Bool        IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const;
      55             : 
      56           0 :     sal_uInt16      GetCode() const
      57           0 :                     { return (nCode & KEY_CODE); }
      58             : 
      59           0 :     sal_uInt16      GetModifier() const
      60           0 :                     { return (nCode & KEY_MODTYPE); }
      61           0 :     sal_uInt16      GetAllModifier() const
      62           0 :                     { return (nCode & KEY_ALLMODTYPE); }
      63           0 :     sal_Bool        IsShift() const
      64           0 :                     { return ((nCode & KEY_SHIFT) != 0); }
      65           0 :     sal_Bool        IsMod1() const
      66           0 :                     { return ((nCode & KEY_MOD1) != 0); }
      67           0 :     sal_Bool        IsMod2() const
      68           0 :                     { return ((nCode & KEY_MOD2) != 0); }
      69           0 :     sal_Bool        IsMod3() const
      70           0 :                     { return ((nCode & KEY_MOD3) != 0); }
      71           0 :     sal_uInt16      GetGroup() const
      72           0 :                     { return (nCode & KEYGROUP_TYPE); }
      73             : 
      74             :     XubString   GetName( Window* pWindow = NULL ) const;
      75             : 
      76          22 :     sal_Bool        IsFunction() const
      77          22 :                     { return ((eFunc != KEYFUNC_DONTKNOW) ? sal_True : sal_False); }
      78             : 
      79             :     KeyFuncType GetFunction() const;
      80             : 
      81             :     KeyCode&    operator = ( const KeyCode& rKeyCode );
      82             :     sal_Bool        operator ==( const KeyCode& rKeyCode ) const;
      83             :     sal_Bool        operator !=( const KeyCode& rKeyCode ) const;
      84             : };
      85             : 
      86           0 : inline KeyCode::KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 )
      87             : {
      88           0 :     nCode = nKey;
      89           0 :     if( bShift )
      90           0 :         nCode |= KEY_SHIFT;
      91           0 :     if( bMod1 )
      92           0 :         nCode |= KEY_MOD1;
      93           0 :     if( bMod2 )
      94           0 :         nCode |= KEY_MOD2;
      95           0 :     if( bMod3 )
      96           0 :         nCode |= KEY_MOD3;
      97           0 :     eFunc = KEYFUNC_DONTKNOW;
      98           0 : }
      99             : 
     100           0 : inline sal_Bool KeyCode::operator ==( const KeyCode& rKeyCode ) const
     101             : {
     102           0 :     if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
     103           0 :         return (nCode == rKeyCode.nCode);
     104             :     else
     105           0 :         return (GetFunction() == rKeyCode.GetFunction());
     106             : }
     107             : 
     108           0 : inline sal_Bool KeyCode::operator !=( const KeyCode& rKeyCode ) const
     109             : {
     110           0 :     if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
     111           0 :         return (nCode != rKeyCode.nCode);
     112             :     else
     113           0 :         return (GetFunction() != rKeyCode.GetFunction());
     114             : }
     115             : 
     116           0 : inline sal_Bool KeyCode::IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const
     117             : {
     118           0 :     if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
     119           0 :         return (GetFullKeyCode() == rKeyCode.GetFullKeyCode());
     120           0 :     return (GetFunction() == rKeyCode.GetFunction());
     121             : }
     122             : 
     123          22 : inline KeyCode& KeyCode::operator = ( const KeyCode& rKeyCode )
     124             : {
     125          22 :     nCode = rKeyCode.nCode;
     126          22 :     eFunc = rKeyCode.eFunc;
     127             : 
     128          22 :     return *this;
     129             : }
     130             : 
     131             : #endif // _SV_KEYCODE_HXX
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10