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