| 1 |
/* |
| 2 |
* This file is part of the LibreOffice project. |
| 3 |
* |
| 4 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
* |
| 8 |
* This file incorporates work covered by the following license notice: |
| 9 |
* |
| 10 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 11 |
* contributor license agreements. See the NOTICE file distributed |
| 12 |
* with this work for additional information regarding copyright |
| 13 |
* ownership. The ASF licenses this file to you under the Apache |
| 14 |
* License, Version 2.0 (the "License"); you may not use this file |
| 15 |
* except in compliance with the License. You may obtain a copy of |
| 16 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 17 |
*/ |
| 18 |
|
| 19 |
package complex.accelerators; |
| 20 |
|
| 21 |
import java.util.HashMap; |
| 22 |
|
| 23 |
class KeyIdentifierInfo |
| 24 |
{ |
| 25 |
protected String sIdentifier; |
| 26 |
protected Short nCode; |
| 27 |
|
| 28 |
KeyIdentifierInfo(String sID, Short nC) |
| 29 |
{ |
| 30 |
sIdentifier = sID; |
| 31 |
nCode = nC; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
class IdentifierHashMap extends HashMap<String,Short> |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
class CodeHashMap extends HashMap<Short,String> |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
public class KeyMapping |
| 44 |
{ |
| 45 |
private final IdentifierHashMap aIdentifierHashMap; |
| 46 |
private final CodeHashMap aCodeHashMap; |
| 47 |
|
| 48 |
public KeyMapping() |
| 49 |
{ |
| 50 |
KeyIdentifierInfo[] aInfoMap = { |
| 51 |
new KeyIdentifierInfo("0", Short.valueOf(com.sun.star.awt.Key.NUM0)), |
| 52 |
new KeyIdentifierInfo("1", Short.valueOf(com.sun.star.awt.Key.NUM1)), |
| 53 |
new KeyIdentifierInfo("2", Short.valueOf(com.sun.star.awt.Key.NUM2)), |
| 54 |
new KeyIdentifierInfo("3", Short.valueOf(com.sun.star.awt.Key.NUM3)), |
| 55 |
new KeyIdentifierInfo("4", Short.valueOf(com.sun.star.awt.Key.NUM4)), |
| 56 |
new KeyIdentifierInfo("5", Short.valueOf(com.sun.star.awt.Key.NUM5)), |
| 57 |
new KeyIdentifierInfo("6", Short.valueOf(com.sun.star.awt.Key.NUM6)), |
| 58 |
new KeyIdentifierInfo("7", Short.valueOf(com.sun.star.awt.Key.NUM7)), |
| 59 |
new KeyIdentifierInfo("8", Short.valueOf(com.sun.star.awt.Key.NUM8)), |
| 60 |
new KeyIdentifierInfo("9", Short.valueOf(com.sun.star.awt.Key.NUM9)), |
| 61 |
new KeyIdentifierInfo("A", Short.valueOf(com.sun.star.awt.Key.A)), |
| 62 |
new KeyIdentifierInfo("B", Short.valueOf(com.sun.star.awt.Key.B)), |
| 63 |
new KeyIdentifierInfo("C", Short.valueOf(com.sun.star.awt.Key.C)), |
| 64 |
new KeyIdentifierInfo("D", Short.valueOf(com.sun.star.awt.Key.D)), |
| 65 |
new KeyIdentifierInfo("E", Short.valueOf(com.sun.star.awt.Key.E)), |
| 66 |
new KeyIdentifierInfo("F", Short.valueOf(com.sun.star.awt.Key.F)), |
| 67 |
new KeyIdentifierInfo("G", Short.valueOf(com.sun.star.awt.Key.G)), |
| 68 |
new KeyIdentifierInfo("H", Short.valueOf(com.sun.star.awt.Key.H)), |
| 69 |
new KeyIdentifierInfo("I", Short.valueOf(com.sun.star.awt.Key.I)), |
| 70 |
new KeyIdentifierInfo("J", Short.valueOf(com.sun.star.awt.Key.J)), |
| 71 |
new KeyIdentifierInfo("K", Short.valueOf(com.sun.star.awt.Key.K)), |
| 72 |
new KeyIdentifierInfo("L", Short.valueOf(com.sun.star.awt.Key.L)), |
| 73 |
new KeyIdentifierInfo("M", Short.valueOf(com.sun.star.awt.Key.M)), |
| 74 |
new KeyIdentifierInfo("N", Short.valueOf(com.sun.star.awt.Key.N)), |
| 75 |
new KeyIdentifierInfo("O", Short.valueOf(com.sun.star.awt.Key.O)), |
| 76 |
new KeyIdentifierInfo("P", Short.valueOf(com.sun.star.awt.Key.P)), |
| 77 |
new KeyIdentifierInfo("Q", Short.valueOf(com.sun.star.awt.Key.Q)), |
| 78 |
new KeyIdentifierInfo("R", Short.valueOf(com.sun.star.awt.Key.R)), |
| 79 |
new KeyIdentifierInfo("S", Short.valueOf(com.sun.star.awt.Key.S)), |
| 80 |
new KeyIdentifierInfo("T", Short.valueOf(com.sun.star.awt.Key.T)), |
| 81 |
new KeyIdentifierInfo("U", Short.valueOf(com.sun.star.awt.Key.U)), |
| 82 |
new KeyIdentifierInfo("V", Short.valueOf(com.sun.star.awt.Key.V)), |
| 83 |
new KeyIdentifierInfo("W", Short.valueOf(com.sun.star.awt.Key.W)), |
| 84 |
new KeyIdentifierInfo("X", Short.valueOf(com.sun.star.awt.Key.X)), |
| 85 |
new KeyIdentifierInfo("Y", Short.valueOf(com.sun.star.awt.Key.Y)), |
| 86 |
new KeyIdentifierInfo("Z", Short.valueOf(com.sun.star.awt.Key.Z)), |
| 87 |
new KeyIdentifierInfo("F1", Short.valueOf(com.sun.star.awt.Key.F1)), |
| 88 |
new KeyIdentifierInfo("F2", Short.valueOf(com.sun.star.awt.Key.F2)), |
| 89 |
new KeyIdentifierInfo("F3", Short.valueOf(com.sun.star.awt.Key.F3)), |
| 90 |
new KeyIdentifierInfo("F4", Short.valueOf(com.sun.star.awt.Key.F4)), |
| 91 |
new KeyIdentifierInfo("F5", Short.valueOf(com.sun.star.awt.Key.F5)), |
| 92 |
new KeyIdentifierInfo("F6", Short.valueOf(com.sun.star.awt.Key.F6)), |
| 93 |
new KeyIdentifierInfo("F7", Short.valueOf(com.sun.star.awt.Key.F7)), |
| 94 |
new KeyIdentifierInfo("F8", Short.valueOf(com.sun.star.awt.Key.F8)), |
| 95 |
new KeyIdentifierInfo("F9", Short.valueOf(com.sun.star.awt.Key.F9)), |
| 96 |
new KeyIdentifierInfo("F10", Short.valueOf(com.sun.star.awt.Key.F10)), |
| 97 |
new KeyIdentifierInfo("F11", Short.valueOf(com.sun.star.awt.Key.F11)), |
| 98 |
new KeyIdentifierInfo("F12", Short.valueOf(com.sun.star.awt.Key.F12)), |
| 99 |
new KeyIdentifierInfo("DOWN", Short.valueOf(com.sun.star.awt.Key.DOWN)), |
| 100 |
new KeyIdentifierInfo("UP", Short.valueOf(com.sun.star.awt.Key.UP)), |
| 101 |
new KeyIdentifierInfo("LEFT", Short.valueOf(com.sun.star.awt.Key.LEFT)), |
| 102 |
new KeyIdentifierInfo("RIGHT", Short.valueOf(com.sun.star.awt.Key.RIGHT)), |
| 103 |
new KeyIdentifierInfo("HOME", Short.valueOf(com.sun.star.awt.Key.HOME)), |
| 104 |
new KeyIdentifierInfo("END", Short.valueOf(com.sun.star.awt.Key.END)), |
| 105 |
new KeyIdentifierInfo("PAGEUP", Short.valueOf(com.sun.star.awt.Key.PAGEUP)), |
| 106 |
new KeyIdentifierInfo("PAGEDOWN", Short.valueOf(com.sun.star.awt.Key.PAGEDOWN)), |
| 107 |
new KeyIdentifierInfo("RETURN", Short.valueOf(com.sun.star.awt.Key.RETURN)), |
| 108 |
new KeyIdentifierInfo("ESCAPE", Short.valueOf(com.sun.star.awt.Key.ESCAPE)), |
| 109 |
new KeyIdentifierInfo("TAB", Short.valueOf(com.sun.star.awt.Key.TAB)), |
| 110 |
new KeyIdentifierInfo("BACKSPACE", Short.valueOf(com.sun.star.awt.Key.BACKSPACE)), |
| 111 |
new KeyIdentifierInfo("SPACE", Short.valueOf(com.sun.star.awt.Key.SPACE)), |
| 112 |
new KeyIdentifierInfo("INSERT", Short.valueOf(com.sun.star.awt.Key.INSERT)), |
| 113 |
new KeyIdentifierInfo("DELETE", Short.valueOf(com.sun.star.awt.Key.DELETE)), |
| 114 |
new KeyIdentifierInfo("ADD", Short.valueOf(com.sun.star.awt.Key.ADD)), |
| 115 |
new KeyIdentifierInfo("SUBTRACT", Short.valueOf(com.sun.star.awt.Key.SUBTRACT)), |
| 116 |
new KeyIdentifierInfo("MULTIPLY", Short.valueOf(com.sun.star.awt.Key.MULTIPLY)), |
| 117 |
new KeyIdentifierInfo("DIVIDE", Short.valueOf(com.sun.star.awt.Key.DIVIDE)), |
| 118 |
new KeyIdentifierInfo("CUT", Short.valueOf(com.sun.star.awt.Key.CUT)), |
| 119 |
new KeyIdentifierInfo("COPY", Short.valueOf(com.sun.star.awt.Key.COPY)), |
| 120 |
new KeyIdentifierInfo("PASTE", Short.valueOf(com.sun.star.awt.Key.PASTE)), |
| 121 |
new KeyIdentifierInfo("UNDO", Short.valueOf(com.sun.star.awt.Key.UNDO)), |
| 122 |
new KeyIdentifierInfo("REPEAT", Short.valueOf(com.sun.star.awt.Key.REPEAT)) |
| 123 |
}; |
| 124 |
|
| 125 |
aIdentifierHashMap = new IdentifierHashMap(); |
| 126 |
aCodeHashMap = new CodeHashMap(); |
| 127 |
for (int i = 0; i<aInfoMap.length; i++) |
| 128 |
{ |
| 129 |
aIdentifierHashMap.put(aInfoMap[i].sIdentifier, aInfoMap[i].nCode); |
| 130 |
aCodeHashMap.put(aInfoMap[i].nCode, aInfoMap[i].sIdentifier); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
public short mapIdentifier2Code(String sIdentifier) |
| 135 |
{ |
| 136 |
return aIdentifierHashMap.get(sIdentifier).shortValue(); |
| 137 |
} |
| 138 |
|
| 139 |
public String mapCode2Identifier(short nCode) |
| 140 |
{ |
| 141 |
return aCodeHashMap.get(Short.valueOf(nCode)); |
| 142 |
} |
| 143 |
} |