xref: /aoo41x/main/vcl/inc/vcl/mnemonic.hxx (revision 0d63794c)
1*0d63794cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0d63794cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0d63794cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0d63794cSAndrew Rist  * distributed with this work for additional information
6*0d63794cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0d63794cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0d63794cSAndrew Rist  * "License"); you may not use this file except in compliance
9*0d63794cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0d63794cSAndrew Rist  *
11*0d63794cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0d63794cSAndrew Rist  *
13*0d63794cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0d63794cSAndrew Rist  * software distributed under the License is distributed on an
15*0d63794cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0d63794cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0d63794cSAndrew Rist  * specific language governing permissions and limitations
18*0d63794cSAndrew Rist  * under the License.
19*0d63794cSAndrew Rist  *
20*0d63794cSAndrew Rist  *************************************************************/
21*0d63794cSAndrew Rist 
22*0d63794cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_MNEMONIC_HXX
25cdf0e10cSrcweir #define _SV_MNEMONIC_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/dllapi.h>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
30cdf0e10cSrcweir #include <com/sun/star/i18n/XCharacterClassification.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // ---------------------
33cdf0e10cSrcweir // - ImplMnemonicTypes -
34cdf0e10cSrcweir // ---------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // Mnemonic Chars, which we want support
37cdf0e10cSrcweir // Latin 0-9
38cdf0e10cSrcweir #define MNEMONIC_RANGE_1_START		0x30
39cdf0e10cSrcweir #define MNEMONIC_RANGE_1_END		0x39
40cdf0e10cSrcweir // Latin A-Z
41cdf0e10cSrcweir #define MNEMONIC_RANGE_2_START		0x41
42cdf0e10cSrcweir #define MNEMONIC_RANGE_2_END		0x5A
43cdf0e10cSrcweir // Cyrillic
44cdf0e10cSrcweir #define MNEMONIC_RANGE_3_START		0x0410
45cdf0e10cSrcweir #define MNEMONIC_RANGE_3_END		0x042F
46cdf0e10cSrcweir // Greek
47cdf0e10cSrcweir #define MNEMONIC_RANGE_4_START		0x0391
48cdf0e10cSrcweir #define MNEMONIC_RANGE_4_END		0x03AB
49cdf0e10cSrcweir #define MNEMONIC_RANGES 			4
50cdf0e10cSrcweir #define MAX_MNEMONICS				((MNEMONIC_RANGE_1_END-MNEMONIC_RANGE_1_START+1)+\
51cdf0e10cSrcweir 									 (MNEMONIC_RANGE_2_END-MNEMONIC_RANGE_2_START+1)+\
52cdf0e10cSrcweir 									 (MNEMONIC_RANGE_3_END-MNEMONIC_RANGE_3_START+1)+\
53cdf0e10cSrcweir 									 (MNEMONIC_RANGE_4_END-MNEMONIC_RANGE_4_START+1))
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define MNEMONIC_CHAR				((sal_Unicode)'~')
56cdf0e10cSrcweir #define MNEMONIC_INDEX_NOTFOUND 	((sal_uInt16)0xFFFF)
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // -------------------------
59cdf0e10cSrcweir // - MnemonicGenerator -
60cdf0e10cSrcweir // -------------------------
61cdf0e10cSrcweir 
62cdf0e10cSrcweir class VCL_DLLPUBLIC MnemonicGenerator
63cdf0e10cSrcweir {
64cdf0e10cSrcweir private:
65cdf0e10cSrcweir 	// 0 == Mnemonic; >0 == count of characters
66cdf0e10cSrcweir 	sal_uInt8				maMnemonics[MAX_MNEMONICS];
67cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > mxCharClass;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir protected:
70cdf0e10cSrcweir 	SAL_DLLPRIVATE sal_uInt16		ImplGetMnemonicIndex( sal_Unicode c );
71cdf0e10cSrcweir 	SAL_DLLPRIVATE sal_Unicode 	ImplFindMnemonic( const XubString& rKey );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir public:
74cdf0e10cSrcweir 						MnemonicGenerator();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	void				RegisterMnemonic( const XubString& rKey );
77cdf0e10cSrcweir 	sal_Bool				CreateMnemonic( XubString& rKey );
78cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > GetCharClass();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     // returns a string where all '~'-characters and CJK mnemonics of the form (~A) are completely removed
81cdf0e10cSrcweir     static String EraseAllMnemonicChars( const String& rStr );
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir #endif // _SV_MNEMONIC_HXX
85