1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implement of class CTruiShortcutsView |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <trui.rsg> |
|
20 #include <e32const.h> |
|
21 #include <PtiMHwrRecognizer.h> |
|
22 #include <PtiLanguage.h> |
|
23 #include <eikenv.h> |
|
24 #include <AknFepInternalCRKeys.h> |
|
25 #include <centralrepository.h> |
|
26 #include <featmgr.h> |
|
27 #include <PtiEngine.h> |
|
28 |
|
29 #include "trui.hrh" |
|
30 #include "truiengine.h" |
|
31 |
|
32 #include "truilanguagerelation.h" |
|
33 |
|
34 const TInt KRangeNamesArraySize = 5; |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // construction |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CTruiEngine::CTruiEngine( CEikonEnv* aEikonEnv ) : iEnv( aEikonEnv ) |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // construction |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 void CTruiEngine::ConstructL() |
|
51 { |
|
52 CRepository* repository = CRepository::NewLC( KCRUidAknFep ); |
|
53 // Get current input language |
|
54 TInt inputLanguage = 0; |
|
55 repository->Get( KAknFepInputTxtLang, inputLanguage ); |
|
56 iInputLanguage = (TLanguage)inputLanguage; |
|
57 |
|
58 // Create PtiEngine |
|
59 iEngine = CPtiEngine::NewL(); |
|
60 MPtiHwrRecognizer* hwr = iEngine->GetHwrRecognizerL( ELangEnglish ); |
|
61 |
|
62 iPtiEngine = hwr->QueryUdmInterfaceL() ; |
|
63 |
|
64 // Initialize a mapping table for language script |
|
65 RArray<TLanguageRelation> languageRelation; |
|
66 CleanupClosePushL( languageRelation ); |
|
67 InitLanguageRelationL( R_TRUI_LANGUAGE_SCRIPT_SET, languageRelation ); |
|
68 |
|
69 // Get all supported language script |
|
70 InitSupportedLanguageScriptL( iSupportedScript, iEngine, languageRelation ); |
|
71 |
|
72 if ( iSupportedScript.Count() == 0 ) |
|
73 { |
|
74 User::Leave( KErrNotSupported ); |
|
75 } |
|
76 |
|
77 // Get currently active language script |
|
78 TInt langCode; |
|
79 repository->Get( KAknFepInputTxtLang, langCode ); |
|
80 TInt activeScript = GetActiveLanguageScript( langCode, languageRelation ); |
|
81 |
|
82 // Destroy the mapping table. |
|
83 CleanupStack::PopAndDestroy( &languageRelation ); |
|
84 CleanupStack::PopAndDestroy( repository ); |
|
85 |
|
86 if ( activeScript != KErrNotFound ) |
|
87 { |
|
88 SetLanguageScriptByIndexL( activeScript ); |
|
89 } |
|
90 else |
|
91 { |
|
92 User::Leave( KErrNotSupported ); |
|
93 } |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // construction |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CTruiEngine* CTruiEngine::NewL( CEikonEnv* aEikonEnv ) |
|
101 { |
|
102 CTruiEngine* self = CTruiEngine::NewLC( aEikonEnv ); |
|
103 CleanupStack::Pop( self ); |
|
104 return self; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // construction |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 CTruiEngine* CTruiEngine::NewLC( CEikonEnv* aEikonEnv ) |
|
112 { |
|
113 CTruiEngine* self = new ( ELeave ) CTruiEngine( aEikonEnv ); |
|
114 CleanupStack::PushL( self ); |
|
115 self->ConstructL(); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // destruction |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CTruiEngine::~CTruiEngine() |
|
124 { |
|
125 iSupportedScript.Close(); |
|
126 if ( iRangeName ) |
|
127 { |
|
128 iRangeName->Reset(); |
|
129 delete iRangeName; |
|
130 } |
|
131 iSupportedRange.Close(); |
|
132 if ( iCharacterSet ) |
|
133 { |
|
134 delete iCharacterSet; |
|
135 } |
|
136 if ( iShortcutList ) |
|
137 { |
|
138 iShortcutList->Reset(); |
|
139 delete iShortcutList; |
|
140 } |
|
141 delete iEngine; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // Set current language script |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CTruiEngine::SetLanguageScriptByIndexL( TInt aIndex ) |
|
149 { |
|
150 //Set script |
|
151 iCurrentScript = aIndex; |
|
152 |
|
153 //Delete previous iRangeName |
|
154 if ( iRangeName ) |
|
155 { |
|
156 delete iRangeName; |
|
157 iRangeName = NULL; |
|
158 } |
|
159 //Reset iSupportedRange |
|
160 iSupportedRange.Reset(); |
|
161 |
|
162 //Set character range |
|
163 HBufC* charRange; |
|
164 switch( iCurrentScript ) |
|
165 { |
|
166 case EMainViewSubmenuWestern: |
|
167 { |
|
168 //There are 5 subranges under Western |
|
169 iRangeName = new (ELeave) CDesCArrayFlat( KRangeNamesArraySize ); |
|
170 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_LOWER ); |
|
171 iRangeName->AppendL( *charRange ); |
|
172 CleanupStack::PopAndDestroy( charRange ); |
|
173 iSupportedRange.Append( ELatinLowerLetters ); |
|
174 |
|
175 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_CAPITAL ); |
|
176 iRangeName->AppendL( *charRange ); |
|
177 CleanupStack::PopAndDestroy( charRange ); |
|
178 iSupportedRange.Append( ELatinUpperLetters ); |
|
179 |
|
180 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_ACCENT ); |
|
181 iRangeName->AppendL( *charRange ); |
|
182 CleanupStack::PopAndDestroy( charRange ); |
|
183 iSupportedRange.Append( ELatinAccent ); |
|
184 |
|
185 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_DIGITS ); |
|
186 iRangeName->AppendL( *charRange ); |
|
187 CleanupStack::PopAndDestroy( charRange ); |
|
188 iSupportedRange.Append( ELatinDigital ); |
|
189 |
|
190 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_SYMBOLS ); |
|
191 iRangeName->AppendL( *charRange ); |
|
192 CleanupStack::PopAndDestroy( charRange ); |
|
193 iSupportedRange.Append( ELatinSymbol ); |
|
194 |
|
195 iPtiEngine->SetLanguageScriptL( EPtiHwrScriptLatin ); |
|
196 break; |
|
197 } |
|
198 case EMainViewSubmenuCyrillic: |
|
199 { |
|
200 //There are 5 subranges under Cyrillic |
|
201 iRangeName = new (ELeave) CDesCArrayFlat( KRangeNamesArraySize ); |
|
202 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CYRILLIC_LOWER ); |
|
203 iRangeName->AppendL( *charRange ); |
|
204 CleanupStack::PopAndDestroy( charRange ); |
|
205 iSupportedRange.Append( ECyrillicLowerLetters ); |
|
206 |
|
207 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CYRILLIC_CAPITAL ); |
|
208 iRangeName->AppendL( *charRange ); |
|
209 CleanupStack::PopAndDestroy( charRange ); |
|
210 iSupportedRange.Append( ECyrillicUpperLetters ); |
|
211 |
|
212 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_DIGITS ); |
|
213 iRangeName->AppendL( *charRange ); |
|
214 CleanupStack::PopAndDestroy( charRange ); |
|
215 iSupportedRange.Append( ELatinDigital ); |
|
216 |
|
217 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_SYMBOLS ); |
|
218 iRangeName->AppendL( *charRange ); |
|
219 CleanupStack::PopAndDestroy( charRange ); |
|
220 iSupportedRange.Append( ELatinSymbol ); |
|
221 |
|
222 iPtiEngine->SetLanguageScriptL( EPtiHwrScriptCyrillic ); |
|
223 break; |
|
224 } |
|
225 case EMainViewSubmenuGreek: |
|
226 { |
|
227 //There are 5 subranges under Greek |
|
228 iRangeName = new (ELeave) CDesCArrayFlat( KRangeNamesArraySize ); |
|
229 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_GREEK_LOWER ); |
|
230 iRangeName->AppendL( *charRange ); |
|
231 CleanupStack::PopAndDestroy( charRange ); |
|
232 iSupportedRange.Append( EGreekLowerLetters ); |
|
233 |
|
234 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_GREEK_CAPITAL ); |
|
235 iRangeName->AppendL( *charRange ); |
|
236 CleanupStack::PopAndDestroy( charRange ); |
|
237 iSupportedRange.Append( EGreekUpperLetters ); |
|
238 |
|
239 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_DIGITS ); |
|
240 iRangeName->AppendL( *charRange ); |
|
241 CleanupStack::PopAndDestroy( charRange ); |
|
242 iSupportedRange.Append( ELatinDigital ); |
|
243 |
|
244 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_SYMBOLS ); |
|
245 iRangeName->AppendL( *charRange ); |
|
246 CleanupStack::PopAndDestroy( charRange ); |
|
247 iSupportedRange.Append( ELatinSymbol ); |
|
248 |
|
249 iPtiEngine->SetLanguageScriptL( EPtiHwrScriptGreek ); |
|
250 break; |
|
251 } |
|
252 case EMainViewSubmenuHebrew: |
|
253 { |
|
254 //There are 4 subranges under Hebrew |
|
255 iRangeName = new (ELeave) CDesCArrayFlat( KRangeNamesArraySize ); |
|
256 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_HEBREW_LETTERS ); |
|
257 iRangeName->AppendL( *charRange ); |
|
258 CleanupStack::PopAndDestroy( charRange ); |
|
259 iSupportedRange.Append( EHebrewLetters ); |
|
260 |
|
261 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_DIGITS ); |
|
262 iRangeName->AppendL( *charRange ); |
|
263 CleanupStack::PopAndDestroy( charRange ); |
|
264 iSupportedRange.Append( ELatinDigital ); |
|
265 |
|
266 charRange = iEnv->AllocReadResourceLC( R_TRUI_MAINVIEW_CHAR_RANGE_SYMBOLS ); |
|
267 iRangeName->AppendL( *charRange ); |
|
268 CleanupStack::PopAndDestroy( charRange ); |
|
269 iSupportedRange.Append( ELatinSymbol ); |
|
270 |
|
271 iPtiEngine->SetLanguageScriptL( EPtiHwrScriptHebrew ); |
|
272 break; |
|
273 } |
|
274 default: |
|
275 { |
|
276 User::Leave( KErrArgument ); |
|
277 } |
|
278 } |
|
279 // Set the first range as the default range |
|
280 SetCharacterRangeByIndexL( 0 ); |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // Set current character range |
|
285 // --------------------------------------------------------------------------- |
|
286 // |
|
287 void CTruiEngine::SetCharacterRangeByIndexL( TInt aIndex ) |
|
288 { |
|
289 iCurrentRange = iSupportedRange[aIndex]; |
|
290 |
|
291 //Update character set by range |
|
292 TInt resourceId= 0; |
|
293 switch( iCurrentRange ) |
|
294 { |
|
295 case ELatinLowerLetters: |
|
296 { |
|
297 resourceId = R_TRUI_CHARACTERSET_LATIN_LOWERLETTERS; |
|
298 break; |
|
299 } |
|
300 case ELatinUpperLetters: |
|
301 { |
|
302 resourceId = R_TRUI_CHARACTERSET_LATIN_UPPERLETTERS; |
|
303 break; |
|
304 } |
|
305 case ELatinAccent: |
|
306 { |
|
307 resourceId = R_TRUI_CHARACTERSET_LATIN_ACCENT; |
|
308 break; |
|
309 } |
|
310 case ELatinDigital: |
|
311 { |
|
312 resourceId = R_TRUI_CHARACTERSET_LATIN_DIGITAL; |
|
313 break; |
|
314 } |
|
315 case ELatinSymbol: |
|
316 { |
|
317 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) ) |
|
318 { |
|
319 resourceId = R_TRUI_CHARACTERSET_LATIN_SYMBOL_CHINESE; |
|
320 } |
|
321 else |
|
322 { |
|
323 resourceId = R_TRUI_CHARACTERSET_LATIN_SYMBOL; |
|
324 } |
|
325 break; |
|
326 } |
|
327 case ECyrillicLowerLetters: |
|
328 { |
|
329 // According to current input language, |
|
330 // Return different resource id. |
|
331 resourceId = CyrillicLowerResourceId( iInputLanguage ); |
|
332 break; |
|
333 } |
|
334 case ECyrillicUpperLetters: |
|
335 { |
|
336 resourceId = CyrillicUpperResourceId( iInputLanguage ); |
|
337 break; |
|
338 } |
|
339 case ECyrillicAccent: |
|
340 { |
|
341 resourceId = R_TRUI_CHARACTERSET_CYRILLIC_ACCENT; |
|
342 break; |
|
343 } |
|
344 case EGreekLowerLetters: |
|
345 { |
|
346 resourceId = R_TRUI_CHARACTERSET_GREEK_LOWERLETTERS; |
|
347 break; |
|
348 } |
|
349 case EGreekUpperLetters: |
|
350 { |
|
351 resourceId = R_TRUI_CHARACTERSET_GREEK_UPPERLETTERS; |
|
352 break; |
|
353 } |
|
354 case EHebrewLetters: |
|
355 { |
|
356 resourceId = R_TRUI_CHARACTERSET_HEBREW_LETTERS; |
|
357 break; |
|
358 } |
|
359 default: |
|
360 { |
|
361 User::Leave( KErrArgument ); |
|
362 } |
|
363 } |
|
364 if ( iCharacterSet ) |
|
365 { |
|
366 delete iCharacterSet; |
|
367 iCharacterSet = NULL; |
|
368 } |
|
369 iCharacterSet = iEnv->AllocReadResourceL( resourceId ); |
|
370 |
|
371 //Transfer character range to engine's subrange and store it in local |
|
372 SetSubrange(); |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // Check if character has model |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 TBool CTruiEngine::CheckCharacterModel( const TDesC& aChar ) |
|
380 { |
|
381 return iPtiEngine->CharacterModelExist( aChar ); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // Delete character model |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 TInt CTruiEngine::DeleteCharacterModel( const TDesC& aChar ) |
|
389 { |
|
390 return iPtiEngine->DeleteCharacterModel( aChar ); |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // Set character model |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void CTruiEngine::SetCharacterModelL( const TDesC& aChar, |
|
398 RArray<TPoint>& aModel, |
|
399 TDes& aSimilarMsg ) |
|
400 { |
|
401 iPtiEngine->SetCharacterModelL( aChar, aModel, iSubrange, aSimilarMsg ); |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // Get character model |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CTruiEngine::GetCharacterModelL( const TDesC& aChar, RArray<TPoint>& aModel ) |
|
409 { |
|
410 iPtiEngine->GetCharacterModelL( aChar, aModel ); |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // Check if shortcut has model |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 TBool CTruiEngine::CheckShortcutModel( const TDesC& aText ) |
|
418 { |
|
419 return iPtiEngine->CheckShortcutModel( aText ); |
|
420 } |
|
421 |
|
422 // --------------------------------------------------------------------------- |
|
423 // Save shortcut text and its assigned character model into PTI Engine |
|
424 // Meanwhile update shortcutlist |
|
425 // --------------------------------------------------------------------------- |
|
426 // |
|
427 void CTruiEngine::SaveShortcutL( const TDesC& aText, |
|
428 RArray<TPoint>& aModel, |
|
429 TDes& aSimilarMsg ) |
|
430 { |
|
431 iPtiEngine->SetShortcutModelL( aText, aModel, aSimilarMsg ); |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------------------------- |
|
435 // Delete shortcut text and its assigned character model from PTI Engine |
|
436 // Meanwhile update shortcutlist |
|
437 // --------------------------------------------------------------------------- |
|
438 // |
|
439 TInt CTruiEngine::DeleteShortcut( const TDesC& aText ) |
|
440 { |
|
441 return iPtiEngine->DeleteShortcutModel( aText ); |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // Set current edited shortcut |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CTruiEngine::SetShortcut( const TDesC& aText ) |
|
449 { |
|
450 iShortcut = aText; |
|
451 return KErrNone; |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // Update Shortcut list |
|
456 // --------------------------------------------------------------------------- |
|
457 // |
|
458 void CTruiEngine::UpdateShortcutListL() |
|
459 { |
|
460 if ( iShortcutList ) |
|
461 { |
|
462 iShortcutList->Reset(); |
|
463 delete iShortcutList; |
|
464 iShortcutList = NULL; |
|
465 } |
|
466 |
|
467 RPointerArray<HBufC> list; |
|
468 CleanupClosePushL( list ); |
|
469 TRAPD( err, iPtiEngine->GetShortcutTextListL( list ) ); |
|
470 if ( err == KErrNone ) |
|
471 { |
|
472 if ( list.Count() > 0 ) |
|
473 { |
|
474 iShortcutList = new (ELeave) CDesCArrayFlat( list.Count() ); |
|
475 for ( TInt i = 0; i < list.Count(); i++ ) |
|
476 { |
|
477 iShortcutList->AppendL( *list[i] ); |
|
478 } |
|
479 iShortcutList->Sort( ECmpCollated ); |
|
480 } |
|
481 } |
|
482 list.ResetAndDestroy(); |
|
483 CleanupStack::PopAndDestroy( &list ); |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------------------------- |
|
487 // From class MTruiEngine. |
|
488 // change the text of an existing shortcut. |
|
489 // --------------------------------------------------------------------------- |
|
490 // |
|
491 void CTruiEngine::ChangeShortcutTextL( const TDesC& aNewText ) |
|
492 { |
|
493 iPtiEngine->ChangeShortcutTextL( iShortcut, aNewText ); |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // Get guiding line pos |
|
498 // --------------------------------------------------------------------------- |
|
499 // |
|
500 TInt CTruiEngine::GetGuidingLinePos( const TSize& aSize, TInt& aTop , TInt& aBottom ) |
|
501 { |
|
502 return iPtiEngine->GetGuidingLinePos( aSize, aTop, aBottom ); |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // Get the number of the maximum of shortcuts |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 TInt CTruiEngine::MaxShortCutLength() |
|
510 { |
|
511 return iPtiEngine->MaxShortCutLength(); |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // Get trails assigned to the specified shortcut. |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 void CTruiEngine::GetShortcutModelL( const TDesC& aText, |
|
519 RArray<TPoint>& aModel, |
|
520 TUint& aUnicode ) |
|
521 { |
|
522 iPtiEngine->GetShortcutModelL( aText, aModel, aUnicode ); |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // Save preset shortcuts. |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 void CTruiEngine::SavePresetShortcutL( TUint aUnicode, const TDesC& aShortcut ) |
|
530 { |
|
531 iPtiEngine->SavePresetShortcutL( aUnicode, aShortcut ); |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------------------------- |
|
535 // Get trails assigned to a preset text. |
|
536 // --------------------------------------------------------------------------- |
|
537 // |
|
538 void CTruiEngine::GetPresetSymbolByUnicodeL( TUint aUnicode, |
|
539 RArray<TPoint>& aModel, |
|
540 TDes& aShortcut ) |
|
541 { |
|
542 iPtiEngine->GetPresetSymbolByUnicodeL( aUnicode, aModel, aShortcut ); |
|
543 } |
|
544 |
|
545 // --------------------------------------------------------------------------- |
|
546 // Return all unicodes of preset text stored in PTI engine. |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 void CTruiEngine::GetAllPresetSymbolsL( RArray<TUint>& aPresets ) |
|
550 { |
|
551 iPtiEngine->GetAllPresetSymbolsL( aPresets ); |
|
552 } |
|
553 |
|
554 // --------------------------------------------------------------------------- |
|
555 // Transform character range to engine's subrange |
|
556 // --------------------------------------------------------------------------- |
|
557 // |
|
558 void CTruiEngine::SetSubrange() |
|
559 { |
|
560 switch( iCurrentRange ) |
|
561 { |
|
562 case ELatinLowerLetters: |
|
563 case ELatinUpperLetters: |
|
564 case ELatinAccent: |
|
565 { |
|
566 iSubrange = EPtiHwrRangeLanguage; |
|
567 break; |
|
568 } |
|
569 case ELatinDigital: |
|
570 { |
|
571 iSubrange = EPtiHwrRangeNumber; |
|
572 break; |
|
573 } |
|
574 case ELatinSymbol: |
|
575 { |
|
576 iSubrange = EPtiHwrRangeSymbol; |
|
577 break; |
|
578 } |
|
579 case ECyrillicLowerLetters: |
|
580 case ECyrillicUpperLetters: |
|
581 case ECyrillicAccent: |
|
582 { |
|
583 iSubrange = EPtiHwrRangeLanguage; |
|
584 break; |
|
585 } |
|
586 case EGreekLowerLetters: |
|
587 case EGreekUpperLetters: |
|
588 { |
|
589 iSubrange = EPtiHwrRangeLanguage; |
|
590 break; |
|
591 } |
|
592 case EHebrewLetters: |
|
593 { |
|
594 iSubrange = EPtiHwrRangeLanguage; |
|
595 break; |
|
596 } |
|
597 default: |
|
598 { |
|
599 iSubrange = EPtiHwrRangeAny; |
|
600 } |
|
601 } |
|
602 } |
|
603 |
|
604 // --------------------------------------------------------------------------- |
|
605 // Initialize the tabel used to map language to language script |
|
606 // --------------------------------------------------------------------------- |
|
607 // |
|
608 void CTruiEngine::InitLanguageRelationL( TInt aResourceId, |
|
609 RArray<TLanguageRelation>& aLanguageRelation ) |
|
610 { |
|
611 TResourceReader reader; |
|
612 iEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
613 TInt script_count = reader.ReadInt16(); |
|
614 for ( TInt i = 0; i < script_count; i++ ) |
|
615 { |
|
616 TInt scriptId = reader.ReadInt16(); |
|
617 TInt lang_count = reader.ReadInt16(); |
|
618 for ( TInt j = 0; j < lang_count; j++ ) |
|
619 { |
|
620 TInt langCode = reader.ReadInt16(); |
|
621 aLanguageRelation.Append( TLanguageRelation( langCode, scriptId ) ); |
|
622 } |
|
623 } |
|
624 CleanupStack::PopAndDestroy(); // reader |
|
625 } |
|
626 |
|
627 // --------------------------------------------------------------------------- |
|
628 // Initialize the supported language script. |
|
629 // --------------------------------------------------------------------------- |
|
630 // |
|
631 void CTruiEngine::InitSupportedLanguageScriptL( RArray<TInt>& aSupportedScript, |
|
632 CPtiEngine* aEngine, |
|
633 const RArray<TLanguageRelation>& aLanguageRelation ) |
|
634 { |
|
635 // Get all supported input language. |
|
636 RArray<TInt> avaiableLanuage; |
|
637 CleanupClosePushL( avaiableLanuage ); |
|
638 aEngine->GetAvailableLanguagesL( avaiableLanuage ); |
|
639 avaiableLanuage.Sort(); |
|
640 |
|
641 // Map language to language script utilizing TLanguageRelation |
|
642 for ( TInt i = 0; i < aLanguageRelation.Count(); i++ ) |
|
643 { |
|
644 TInt languageScriptId = aLanguageRelation[i].LanguageScriptId(); |
|
645 if ( aSupportedScript.Find( languageScriptId ) == KErrNotFound ) |
|
646 { |
|
647 TInt languageCode = aLanguageRelation[i].LanguageCode(); |
|
648 if ( avaiableLanuage.FindInOrder( languageCode ) != KErrNotFound ) |
|
649 { |
|
650 // Add language to aSupportedScript |
|
651 aSupportedScript.Append( languageScriptId ); |
|
652 } |
|
653 } |
|
654 } |
|
655 |
|
656 CleanupStack::PopAndDestroy( &avaiableLanuage ); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // Initialize the supported language script. |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 TInt CTruiEngine::GetActiveLanguageScript( TInt aLanguageCode, |
|
664 const RArray<TLanguageRelation>& aLanguageRelation ) |
|
665 { |
|
666 for ( TInt i = 0; i < aLanguageRelation.Count(); i++ ) |
|
667 { |
|
668 if ( aLanguageCode == aLanguageRelation[i].LanguageCode() ) |
|
669 { |
|
670 return aLanguageRelation[i].LanguageScriptId(); |
|
671 } |
|
672 } |
|
673 return KErrNotFound; |
|
674 } |
|
675 |
|
676 // --------------------------------------------------------------------------- |
|
677 // Get the resourc id of lower case of Cyrillic |
|
678 // according to the current input language. |
|
679 // --------------------------------------------------------------------------- |
|
680 // |
|
681 TInt CTruiEngine::CyrillicLowerResourceId( TLanguage aLanguage ) |
|
682 { |
|
683 if ( aLanguage == ELangBulgarian ) |
|
684 { |
|
685 return R_TRUI_CHARACTERSET_CYRILLIC_LOWERLETTERS_BULGARIAN; |
|
686 } |
|
687 else if ( aLanguage == ELangRussian ) |
|
688 { |
|
689 return R_TRUI_CHARACTERSET_CYRILLIC_LOWERLETTERS_RUSSIAN; |
|
690 } |
|
691 else if ( aLanguage == ELangUkrainian ) |
|
692 { |
|
693 return R_TRUI_CHARACTERSET_CYRILLIC_LOWERLETTERS_UKRAINE; |
|
694 } |
|
695 else |
|
696 { |
|
697 return R_TRUI_CHARACTERSET_CYRILLIC_LOWERLETTERS; |
|
698 } |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------------------------- |
|
702 // Get the resourc id of upper case of Cyrillic |
|
703 // according to the current input language. |
|
704 // --------------------------------------------------------------------------- |
|
705 // |
|
706 TInt CTruiEngine::CyrillicUpperResourceId( TLanguage aLanguage ) |
|
707 { |
|
708 if ( aLanguage == ELangBulgarian ) |
|
709 { |
|
710 return R_TRUI_CHARACTERSET_CYRILLIC_UPPERLETTERS_BULGARIAN; |
|
711 } |
|
712 else if ( aLanguage == ELangRussian ) |
|
713 { |
|
714 return R_TRUI_CHARACTERSET_CYRILLIC_UPPERLETTERS_RUSSIAN; |
|
715 } |
|
716 else if ( aLanguage == ELangUkrainian ) |
|
717 { |
|
718 return R_TRUI_CHARACTERSET_CYRILLIC_UPPERLETTERS_UKRAINE; |
|
719 } |
|
720 else |
|
721 { |
|
722 return R_TRUI_CHARACTERSET_CYRILLIC_UPPERLETTERS; |
|
723 } |
|
724 } |
|
725 |
|