1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_ 25*b1cdbd2cSJim Jagielski #define __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski //__________________________________________ 28*b1cdbd2cSJim Jagielski // own includes 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski #include <general.h> 31*b1cdbd2cSJim Jagielski #include <stdtypes.h> 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski //__________________________________________ 34*b1cdbd2cSJim Jagielski // interface includes 35*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/IllegalArgumentException.hpp> 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski //__________________________________________ 38*b1cdbd2cSJim Jagielski // other includes 39*b1cdbd2cSJim Jagielski 40*b1cdbd2cSJim Jagielski //__________________________________________ 41*b1cdbd2cSJim Jagielski // definition 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski namespace framework 44*b1cdbd2cSJim Jagielski { 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski //__________________________________________ 47*b1cdbd2cSJim Jagielski /** 48*b1cdbd2cSJim Jagielski can be used to map key identifier to the 49*b1cdbd2cSJim Jagielski corresponding key codes ... 50*b1cdbd2cSJim Jagielski */ 51*b1cdbd2cSJim Jagielski class KeyMapping 52*b1cdbd2cSJim Jagielski { 53*b1cdbd2cSJim Jagielski //______________________________________ 54*b1cdbd2cSJim Jagielski // const, types 55*b1cdbd2cSJim Jagielski 56*b1cdbd2cSJim Jagielski private: 57*b1cdbd2cSJim Jagielski 58*b1cdbd2cSJim Jagielski //--------------------------------------- 59*b1cdbd2cSJim Jagielski /** @short is used to map a key code 60*b1cdbd2cSJim Jagielski to the right key identifier, which is 61*b1cdbd2cSJim Jagielski used to make the xml file "human readable" 62*b1cdbd2cSJim Jagielski */ 63*b1cdbd2cSJim Jagielski struct KeyIdentifierInfo 64*b1cdbd2cSJim Jagielski { 65*b1cdbd2cSJim Jagielski sal_Int16 Code ; 66*b1cdbd2cSJim Jagielski const char* Identifier; 67*b1cdbd2cSJim Jagielski }; 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski //--------------------------------------- 70*b1cdbd2cSJim Jagielski /** @short hash structure to map identifier to key codes. */ 71*b1cdbd2cSJim Jagielski typedef BaseHash< sal_Int16 > Identifier2CodeHash; 72*b1cdbd2cSJim Jagielski 73*b1cdbd2cSJim Jagielski //--------------------------------------- 74*b1cdbd2cSJim Jagielski /** @short hash structure to map key codes to identifier. */ 75*b1cdbd2cSJim Jagielski typedef ::std::hash_map< sal_Int16 , 76*b1cdbd2cSJim Jagielski ::rtl::OUString , 77*b1cdbd2cSJim Jagielski ShortHashCode , 78*b1cdbd2cSJim Jagielski ::std::equal_to< sal_Int16 > > Code2IdentifierHash; 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski //______________________________________ 81*b1cdbd2cSJim Jagielski // member 82*b1cdbd2cSJim Jagielski 83*b1cdbd2cSJim Jagielski private: 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski static KeyIdentifierInfo KeyIdentifierMap[]; 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski //--------------------------------------- 88*b1cdbd2cSJim Jagielski /** @short hash to map identifier to key codes. */ 89*b1cdbd2cSJim Jagielski Identifier2CodeHash m_lIdentifierHash; 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski //--------------------------------------- 92*b1cdbd2cSJim Jagielski /** @short hash to map key codes to identifier. */ 93*b1cdbd2cSJim Jagielski Code2IdentifierHash m_lCodeHash; 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski //______________________________________ 96*b1cdbd2cSJim Jagielski // interface 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski public: 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielski KeyMapping(); 101*b1cdbd2cSJim Jagielski virtual ~KeyMapping(); 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski //---------------------------------- 104*b1cdbd2cSJim Jagielski /** @short return a suitable key code 105*b1cdbd2cSJim Jagielski for the specified key identifier. 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski @param sIdentifier 108*b1cdbd2cSJim Jagielski string value, which describe the key. 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski @return [css::awt::KeyEvent] 111*b1cdbd2cSJim Jagielski the corresponding key code as 112*b1cdbd2cSJim Jagielski short value. 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski @throw [css::lang::IllegalArgumentException] 115*b1cdbd2cSJim Jagielski if the given identifier does not describe 116*b1cdbd2cSJim Jagielski a well known key code. 117*b1cdbd2cSJim Jagielski */ 118*b1cdbd2cSJim Jagielski virtual sal_uInt16 mapIdentifierToCode(const ::rtl::OUString& sIdentifier) 119*b1cdbd2cSJim Jagielski throw(css::lang::IllegalArgumentException); 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski //---------------------------------- 122*b1cdbd2cSJim Jagielski /** @short return a suitable key identifier 123*b1cdbd2cSJim Jagielski for the specified key code. 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski @param nCode 126*b1cdbd2cSJim Jagielski short value, which describe the key. 127*b1cdbd2cSJim Jagielski 128*b1cdbd2cSJim Jagielski @return The corresponding string identifier. 129*b1cdbd2cSJim Jagielski */ 130*b1cdbd2cSJim Jagielski virtual ::rtl::OUString mapCodeToIdentifier(sal_uInt16 nCode); 131*b1cdbd2cSJim Jagielski 132*b1cdbd2cSJim Jagielski //______________________________________ 133*b1cdbd2cSJim Jagielski // helper 134*b1cdbd2cSJim Jagielski 135*b1cdbd2cSJim Jagielski private: 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski //---------------------------------- 138*b1cdbd2cSJim Jagielski /** @short check if the given string describe a numeric 139*b1cdbd2cSJim Jagielski value ... and convert it. 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim Jagielski @param sIdentifier 142*b1cdbd2cSJim Jagielski the string value, which should be converted. 143*b1cdbd2cSJim Jagielski 144*b1cdbd2cSJim Jagielski 145*b1cdbd2cSJim Jagielski @param rCode 146*b1cdbd2cSJim Jagielski contains the converted code, but is defined only 147*b1cdbd2cSJim Jagielski if this method returns sal_True! 148*b1cdbd2cSJim Jagielski 149*b1cdbd2cSJim Jagielski @return [boolean] 150*b1cdbd2cSJim Jagielski sal_True if convertion was successfully. 151*b1cdbd2cSJim Jagielski */ 152*b1cdbd2cSJim Jagielski sal_Bool impl_st_interpretIdentifierAsPureKeyCode(const ::rtl::OUString& sIdentifier, 153*b1cdbd2cSJim Jagielski sal_uInt16& rCode ); 154*b1cdbd2cSJim Jagielski }; 155*b1cdbd2cSJim Jagielski 156*b1cdbd2cSJim Jagielski } // namespace framework 157*b1cdbd2cSJim Jagielski 158*b1cdbd2cSJim Jagielski #endif // __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_ 159