LCOV - code coverage report
Current view: top level - include/vcl - keycod.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 30 47 63.8 %
Date: 2014-11-03 Functions: 9 16 56.2 %
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             : namespace vcl { class Window; }
      30             : 
      31             : namespace vcl
      32             : {
      33             : 
      34             : class VCL_DLLPUBLIC KeyCode
      35             : {
      36             : private:
      37             :     sal_uInt16      nKeyCodeAndModifiers;
      38             :     KeyFuncType     eFunc;
      39             : 
      40             : public:
      41     1051337 :                     KeyCode() { nKeyCodeAndModifiers = 0; eFunc = KeyFuncType::DONTKNOW; }
      42             :                     KeyCode( const ResId& rResId );
      43             :                     KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 );
      44             :                     KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 );
      45             :                     KeyCode( KeyFuncType eFunction );
      46             : 
      47      100312 :     sal_uInt16      GetFullCode() const { return nKeyCodeAndModifiers; }
      48           0 :     KeyFuncType     GetFullFunction() const { return eFunc; }
      49             : 
      50        1248 :     sal_uInt16      GetCode() const
      51        1248 :                     { return (nKeyCodeAndModifiers & KEY_CODE); }
      52             : 
      53           6 :     sal_uInt16      GetModifier() const
      54           6 :                     { return (nKeyCodeAndModifiers & KEY_MODTYPE); }
      55           0 :     bool            IsShift() const
      56           0 :                     { return ((nKeyCodeAndModifiers & KEY_SHIFT) != 0); }
      57           0 :     bool            IsMod1() const
      58           0 :                     { return ((nKeyCodeAndModifiers & KEY_MOD1) != 0); }
      59           0 :     bool            IsMod2() const
      60           0 :                     { return ((nKeyCodeAndModifiers & KEY_MOD2) != 0); }
      61           0 :     bool            IsMod3() const
      62           0 :                     { return ((nKeyCodeAndModifiers & KEY_MOD3) != 0); }
      63           0 :     sal_uInt16      GetGroup() const
      64           0 :                     { return (nKeyCodeAndModifiers & KEYGROUP_TYPE); }
      65             : 
      66             :     OUString        GetName( vcl::Window* pWindow = NULL ) const;
      67             : 
      68       10586 :     bool            IsFunction() const
      69       10586 :                     { return (eFunc != KeyFuncType::DONTKNOW); }
      70             : 
      71             :     KeyFuncType     GetFunction() const;
      72             : 
      73             :     KeyCode&        operator = ( const KeyCode& rKeyCode );
      74             :     bool            operator ==( const KeyCode& rKeyCode ) const;
      75             :     bool            operator !=( const KeyCode& rKeyCode ) const;
      76             : };
      77             : 
      78             : } // namespace vcl
      79             : 
      80       10776 : inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier )
      81             : {
      82       10776 :     nKeyCodeAndModifiers = nKey | nModifier;
      83       10776 :     eFunc = KeyFuncType::DONTKNOW;
      84       10776 : }
      85             : 
      86       89546 : inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 )
      87             : {
      88       89546 :     nKeyCodeAndModifiers = nKey;
      89       89546 :     if( bShift )
      90       25066 :         nKeyCodeAndModifiers |= KEY_SHIFT;
      91       89546 :     if( bMod1 )
      92       81394 :         nKeyCodeAndModifiers |= KEY_MOD1;
      93       89546 :     if( bMod2 )
      94         850 :         nKeyCodeAndModifiers |= KEY_MOD2;
      95       89546 :     if( bMod3 )
      96           0 :         nKeyCodeAndModifiers |= KEY_MOD3;
      97       89546 :     eFunc = KeyFuncType::DONTKNOW;
      98       89546 : }
      99             : 
     100       18258 : inline bool vcl::KeyCode::operator ==( const vcl::KeyCode& rKeyCode ) const
     101             : {
     102       18258 :     if ( (eFunc == KeyFuncType::DONTKNOW) && (rKeyCode.eFunc == KeyFuncType::DONTKNOW) )
     103       18258 :         return (nKeyCodeAndModifiers == rKeyCode.nKeyCodeAndModifiers);
     104             :     else
     105           0 :         return (GetFunction() == rKeyCode.GetFunction());
     106             : }
     107             : 
     108           0 : inline bool vcl::KeyCode::operator !=( const vcl::KeyCode& rKeyCode ) const
     109             : {
     110           0 :     if ( (eFunc == KeyFuncType::DONTKNOW) && (rKeyCode.eFunc == KeyFuncType::DONTKNOW) )
     111           0 :         return (nKeyCodeAndModifiers != rKeyCode.nKeyCodeAndModifiers);
     112             :     else
     113           0 :         return (GetFunction() != rKeyCode.GetFunction());
     114             : }
     115             : 
     116       13740 : inline vcl::KeyCode& vcl::KeyCode::operator = ( const vcl::KeyCode& rKeyCode )
     117             : {
     118       13740 :     nKeyCodeAndModifiers = rKeyCode.nKeyCodeAndModifiers;
     119       13740 :     eFunc = rKeyCode.eFunc;
     120             : 
     121       13740 :     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