[Libreoffice-commits] core.git: include/vcl

Noel Grandin noel at peralex.com
Sat Nov 1 00:16:35 PDT 2014


 include/vcl/keycod.hxx |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

New commits:
commit 9044260c35b22aeb6fdecee35a6ac34bb660ee35
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Oct 31 09:07:35 2014 +0200

    add some asserts to validate KeyCode values
    
    Change-Id: I1b4b8d44f11086ed994a093fef0029982fac2c63
    Reviewed-on: https://gerrit.libreoffice.org/12161
    Tested-by: LibreOffice gerrit bot <gerrit at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/vcl/keycod.hxx b/include/vcl/keycod.hxx
index 3c96d45..a82a2de 100644
--- a/include/vcl/keycod.hxx
+++ b/include/vcl/keycod.hxx
@@ -38,12 +38,11 @@ private:
     KeyFuncType     eFunc;
 
 public:
-                KeyCode() { nKeyCodeAndModifiers = 0; eFunc = KeyFuncType::DONTKNOW; }
-                KeyCode( const ResId& rResId );
-                KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 )
-                    { nKeyCodeAndModifiers = nKey | nModifier; eFunc = KeyFuncType::DONTKNOW; }
-                KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 );
-                KeyCode( KeyFuncType eFunction );
+                    KeyCode() { nKeyCodeAndModifiers = 0; eFunc = KeyFuncType::DONTKNOW; }
+                    KeyCode( const ResId& rResId );
+                    KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 );
+                    KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 );
+                    KeyCode( KeyFuncType eFunction );
 
     sal_uInt16      GetFullCode() const { return nKeyCodeAndModifiers; }
     KeyFuncType     GetFullFunction() const { return eFunc; }
@@ -78,8 +77,17 @@ public:
 
 } // namespace vcl
 
+inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier )
+{
+    assert(nKey <= KEY_CODE);
+    assert(nModifier >= KEY_MODTYPE);
+    nKeyCodeAndModifiers = nKey | nModifier;
+    eFunc = KeyFuncType::DONTKNOW;
+}
+
 inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 )
 {
+    assert(nKey <= KEY_CODE);
     nKeyCodeAndModifiers = nKey;
     if( bShift )
         nKeyCodeAndModifiers |= KEY_SHIFT;


More information about the Libreoffice-commits mailing list