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

Generated by: LCOV version 1.10