44
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Implementation for chinese peninput finger hwr
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
//SYSTEM INCLUDE
|
|
18 |
#include <centralrepository.h>
|
|
19 |
#include <settingsinternalcrkeys.h>
|
|
20 |
|
|
21 |
//FEP INCLUDE
|
|
22 |
#include <aknfeppeninputenums.h>
|
|
23 |
#include <AknFepGlobalEnums.h>
|
|
24 |
#include <AknFepInternalCRKeys.h>
|
|
25 |
|
|
26 |
//USER INCLUDE
|
|
27 |
#include "peninputfingerhwrlayout.h"
|
|
28 |
#include "peninputfingerhwrdatastore.h"
|
|
29 |
#include "peninputfingerhwrtriggerstr.h"
|
|
30 |
#include "peninputfingerhwrengine.h"
|
|
31 |
#include "peninputpluginutils.h"
|
|
32 |
#include "peninputfingerhwrstoreconstants.h"
|
|
33 |
#include <peninputfingerhwrcn.rsg>
|
|
34 |
|
|
35 |
//CONSTANT DEFINATION HEADER
|
|
36 |
|
|
37 |
|
|
38 |
// ----------------------------------------------------------------------------
|
|
39 |
// Symbian constructor
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CPeninputFingerHwrDataStore* CPeninputFingerHwrDataStore::NewL(
|
|
43 |
CPtiEngine* aPtiEngine, CPeninputFingerHwrLayout* aLayout )
|
|
44 |
{
|
|
45 |
CPeninputFingerHwrDataStore* self = new ( ELeave )
|
|
46 |
CPeninputFingerHwrDataStore(aLayout);
|
|
47 |
|
|
48 |
CleanupStack::PushL( self );
|
|
49 |
self->ConstructL( aPtiEngine );
|
|
50 |
CleanupStack::Pop( self );//self
|
|
51 |
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
// ----------------------------------------------------------------------------
|
|
56 |
// destructor
|
|
57 |
// ----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CPeninputFingerHwrDataStore::~CPeninputFingerHwrDataStore()
|
|
60 |
{
|
|
61 |
iCandidates.ResetAndDestroy();
|
|
62 |
iCandidates.Close();
|
|
63 |
|
|
64 |
iPredictives.ResetAndDestroy();
|
|
65 |
iPredictives.Close();
|
|
66 |
|
|
67 |
iRangeStartPos.Close();
|
|
68 |
iPermittedRanges.Close();
|
|
69 |
iKeyMappingIdList.Close();
|
|
70 |
|
|
71 |
iKeyMappingStringList.ResetAndDestroy();
|
|
72 |
iKeyMappingStringList.Close();
|
|
73 |
|
|
74 |
delete iRepositoryFep;
|
|
75 |
delete iTriggerStr;
|
|
76 |
delete iHwrEngine;
|
|
77 |
delete iUserDefinedResource;
|
|
78 |
|
|
79 |
if ( iDefaultNumberMapping )
|
|
80 |
{
|
|
81 |
delete iDefaultNumberMapping;
|
|
82 |
}
|
|
83 |
iDefaultNumberMapping = NULL;
|
|
84 |
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
// Is valid candidate
|
|
90 |
// ----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
TBool CPeninputFingerHwrDataStore::IsValidCandidate( TInt aCandidateIndex ) const
|
|
93 |
{
|
|
94 |
return ( *iCandidates[aCandidateIndex] ).Length() > 0;
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
// ----------------------------------------------------------------------------
|
|
99 |
// Is English letter
|
|
100 |
// ----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
TBool CPeninputFingerHwrDataStore::IsEnglishLetter( const TDesC& aLetter)
|
|
103 |
{
|
|
104 |
TUint unicode = *((TUint16*) aLetter.Ptr());
|
|
105 |
|
|
106 |
const TUint ACode = 0x0041; // Letter "A"
|
|
107 |
const TUint ZCode = 0x005A; // Letter "Z"
|
|
108 |
const TUint aCode = 0x0061; // Letter "a"
|
|
109 |
const TUint zCode = 0x007A; // Letter "z"
|
|
110 |
|
|
111 |
if( ((ACode <= unicode) && (unicode <= ZCode))||
|
|
112 |
((aCode <= unicode) && (unicode <= zCode)) )
|
|
113 |
{
|
|
114 |
return ETrue;
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
return EFalse;
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
// ----------------------------------------------------------------------------
|
|
123 |
// Do recoginize by engine for Chinese
|
|
124 |
// ----------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
void CPeninputFingerHwrDataStore::DoChineseRecognizeL( const RArray<TPoint>& aTraceData )
|
|
127 |
{
|
|
128 |
iHwrEngine->DoRecognizeL( aTraceData, iCandidates );
|
|
129 |
|
|
130 |
// To set candidate and do predictive
|
|
131 |
SetCandidatesL();
|
|
132 |
}
|
|
133 |
|
|
134 |
|
|
135 |
// ----------------------------------------------------------------------------
|
|
136 |
// Do recoginize by engine for English
|
|
137 |
// ----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CPeninputFingerHwrDataStore::DoEngRecognizeL( const RArray<TPoint>& aTraceData )
|
|
140 |
{
|
|
141 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
142 |
iHwrEngine->DoRecognizeL( aTraceData, iCandidates );
|
|
143 |
// To set candiate and do auto complete
|
|
144 |
SetAutoCompleteCandidatesL();
|
|
145 |
#else
|
|
146 |
iHwrEngine->DoRecognizeL( aTraceData, iPredictives );
|
|
147 |
#endif // RD_INTELLIGENT_TEXT_INPUT
|
|
148 |
}
|
|
149 |
|
|
150 |
|
|
151 |
// ----------------------------------------------------------------------------
|
|
152 |
// Do predictive using trigger string
|
|
153 |
// ----------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CPeninputFingerHwrDataStore::DoPredictiveL()
|
|
156 |
{
|
|
157 |
// clear the predictives
|
|
158 |
iPredictives.ResetAndDestroy();
|
|
159 |
|
|
160 |
TInt primaryRange = iPermittedRanges[0];
|
|
161 |
TPtrC string = TriggerStr()->GetString();
|
|
162 |
|
|
163 |
if( primaryRange == ERangeNative )
|
|
164 |
{
|
|
165 |
iHwrEngine->DoPredictiveL( string, iPredictives );
|
|
166 |
}
|
|
167 |
|
|
168 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
169 |
if( primaryRange == ERangeEnglish )
|
|
170 |
{ // only for auto complete
|
|
171 |
if(!IsEnglishLetter(string.Right(1)))
|
|
172 |
{
|
|
173 |
// clear the predictives when input non-letter.
|
|
174 |
iPredictives.ResetAndDestroy();
|
|
175 |
}
|
|
176 |
else
|
|
177 |
{
|
|
178 |
iHwrEngine->DoEngPredictiveL( string, iPredictives );
|
|
179 |
// Remove all the accent symbol from auto complete candidate
|
|
180 |
RemoveAccent();
|
|
181 |
}
|
|
182 |
}
|
|
183 |
#endif // No predictive candidate when auto complete is off
|
|
184 |
}
|
|
185 |
|
|
186 |
|
|
187 |
// ----------------------------------------------------------------------------
|
|
188 |
// Set fixed Chinese symbols
|
|
189 |
// ----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CPeninputFingerHwrDataStore::SetChineseSymbolL()
|
|
192 |
{
|
|
193 |
iCandidates.ResetAndDestroy();
|
|
194 |
TInt symCount = sizeof( ChineseSymbolCode )/sizeof( TUint16 );
|
|
195 |
|
|
196 |
for( TInt i = 0; i < symCount; i++ )
|
|
197 |
{
|
|
198 |
TBuf<1> charBuf;
|
|
199 |
charBuf.Append( ChineseSymbolCode[i] );
|
|
200 |
|
|
201 |
iCandidates.AppendL( charBuf.AllocL() );
|
|
202 |
}
|
|
203 |
|
|
204 |
}
|
|
205 |
|
|
206 |
// ----------------------------------------------------------------------------
|
|
207 |
// Set fixed Chinese predictives
|
|
208 |
// ----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CPeninputFingerHwrDataStore::SetFixChinesePredictiveL()
|
|
211 |
{
|
|
212 |
iPredictives.ResetAndDestroy();
|
|
213 |
TInt symCount = sizeof( ChinesePredictCode )/sizeof( TUint16 );
|
|
214 |
|
|
215 |
for( TInt i = 0; i < symCount; i++ )
|
|
216 |
{
|
|
217 |
TBuf<1> charBuf;
|
|
218 |
charBuf.Append( ChinesePredictCode[i] );
|
|
219 |
|
|
220 |
iPredictives.AppendL( charBuf.AllocL() );
|
|
221 |
}
|
|
222 |
}
|
|
223 |
|
|
224 |
// ----------------------------------------------------------------------------
|
|
225 |
// Set fixed English symbols
|
|
226 |
// ----------------------------------------------------------------------------
|
|
227 |
//
|
|
228 |
void CPeninputFingerHwrDataStore::SetFixEnglishSymbolL(TRowCount aRowCount)
|
|
229 |
{
|
|
230 |
TInt symCount = 0;
|
|
231 |
|
|
232 |
switch(aRowCount)
|
|
233 |
{
|
|
234 |
case ERowOne: // only set one row dropdownlist
|
|
235 |
{
|
|
236 |
iCandidates.ResetAndDestroy();
|
|
237 |
symCount = sizeof( EnglishSymbolCodeOneRow )/sizeof( TUint16 );
|
|
238 |
for( TInt i = 0; i < symCount; i++ )
|
|
239 |
{
|
|
240 |
TBuf<1> charBuf;
|
|
241 |
charBuf.Append( EnglishSymbolCodeOneRow[i] );
|
|
242 |
iCandidates.AppendL( charBuf.AllocL() );
|
|
243 |
}
|
|
244 |
}
|
|
245 |
break;
|
|
246 |
case ERowTwo: // Set two rows dropdownlist
|
|
247 |
{
|
|
248 |
iCandidates.ResetAndDestroy();
|
|
249 |
iPredictives.ResetAndDestroy();
|
|
250 |
symCount = sizeof( EnglishSymbolCodeTwoRow )/sizeof( TUint16 );
|
|
251 |
|
|
252 |
for( TInt i = 0; i < symCount; i++ )
|
|
253 |
{
|
|
254 |
TBuf<1> charBuf1; // the first row
|
|
255 |
TBuf<2> charBuf2; // the second row
|
|
256 |
|
|
257 |
charBuf1.Append( EnglishSymbolCodeOneRow[i] );
|
|
258 |
iCandidates.AppendL( charBuf1.AllocL() );
|
|
259 |
|
|
260 |
if(i > 2) // for smile symbol
|
|
261 |
{
|
|
262 |
charBuf2.Append(ColonSymbol);
|
|
263 |
}
|
|
264 |
charBuf2.Append( EnglishSymbolCodeTwoRow[i] );
|
|
265 |
|
|
266 |
iPredictives.AppendL( charBuf2.AllocL() );
|
|
267 |
}
|
|
268 |
}
|
|
269 |
break;
|
|
270 |
default:
|
|
271 |
break;
|
|
272 |
}
|
|
273 |
}
|
|
274 |
|
|
275 |
// ----------------------------------------------------------------------------
|
|
276 |
// Get the predictive count
|
|
277 |
// ----------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
TInt CPeninputFingerHwrDataStore::PredictiveCount() const
|
|
280 |
{
|
|
281 |
return iPredictives.Count();
|
|
282 |
}
|
|
283 |
|
|
284 |
// ----------------------------------------------------------------------------
|
|
285 |
// Get the trigger string
|
|
286 |
// ----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
CAknFepHwrTriggerStr* CPeninputFingerHwrDataStore::TriggerStr() const
|
|
289 |
{
|
|
290 |
return iTriggerStr;
|
|
291 |
}
|
|
292 |
|
|
293 |
// ----------------------------------------------------------------------------
|
|
294 |
// Set permitted ranges
|
|
295 |
// ----------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
void CPeninputFingerHwrDataStore::SetPermittedRanges( TInt aPermittedRanges )
|
|
298 |
{
|
|
299 |
if(aPermittedRanges == 0)
|
|
300 |
return;
|
|
301 |
|
|
302 |
iPermittedRanges.Reset();
|
|
303 |
|
|
304 |
//order can not be changed
|
|
305 |
if ( aPermittedRanges & ERangeNative )
|
|
306 |
{
|
|
307 |
iPermittedRanges.Append( ERangeNative );
|
|
308 |
}
|
|
309 |
if ( aPermittedRanges & ERangeEnglish )
|
|
310 |
{
|
|
311 |
iPermittedRanges.Append( ERangeEnglish );
|
|
312 |
}
|
|
313 |
if ( aPermittedRanges & ERangeNumber )
|
|
314 |
{
|
|
315 |
iPermittedRanges.Append( ERangeNumber );
|
|
316 |
}
|
|
317 |
if ( aPermittedRanges & ERangeSymbol )
|
|
318 |
{
|
|
319 |
iPermittedRanges.Append( ERangeSymbol );
|
|
320 |
}
|
|
321 |
|
|
322 |
iIntRange = aPermittedRanges;
|
|
323 |
|
|
324 |
// set primary and auxiliary ranges for hwr engine
|
|
325 |
iHwrEngine->SetRanges( iPermittedRanges );
|
|
326 |
}
|
|
327 |
|
|
328 |
|
|
329 |
// ----------------------------------------------------------------------------
|
|
330 |
// Set permitted cases
|
|
331 |
// ----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CPeninputFingerHwrDataStore::SetPermittedCases( TInt aPermittedCases )
|
|
334 |
{
|
|
335 |
iPermittedCases = aPermittedCases;
|
|
336 |
}
|
|
337 |
|
|
338 |
// ----------------------------------------------------------------------------
|
|
339 |
// Set Primary range
|
|
340 |
// ----------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
void CPeninputFingerHwrDataStore::SetPrimaryRange( TInt aPrimaryRange )
|
|
343 |
{
|
|
344 |
const TInt oldIndex = iPermittedRanges.Find( aPrimaryRange );
|
|
345 |
|
|
346 |
// store the current range
|
|
347 |
switch(aPrimaryRange)
|
|
348 |
{
|
|
349 |
case ERangeNative:
|
|
350 |
{
|
|
351 |
iCurrentRange = EFingerHwrNativeRange;
|
|
352 |
}
|
|
353 |
break;
|
|
354 |
case ERangeEnglish:
|
|
355 |
{
|
|
356 |
iCurrentRange = EFingerHwrEnglishRange;
|
|
357 |
}
|
|
358 |
break;
|
|
359 |
case ERangeNumber:
|
|
360 |
{
|
|
361 |
iCurrentRange = EFingerHwrNumberRange;
|
|
362 |
}
|
|
363 |
break;
|
|
364 |
default:
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
|
|
368 |
if ( oldIndex > 0 )
|
|
369 |
{
|
|
370 |
iPermittedRanges.Sort();
|
|
371 |
const TInt index = iPermittedRanges.Find( aPrimaryRange );
|
|
372 |
|
|
373 |
iPermittedRanges.Remove( index );
|
|
374 |
iPermittedRanges.Insert( aPrimaryRange, 0 );
|
|
375 |
|
|
376 |
// set primary range for hwr engine
|
|
377 |
iHwrEngine->SetRanges( iPermittedRanges );
|
|
378 |
}
|
|
379 |
}
|
|
380 |
|
|
381 |
// ----------------------------------------------------------------------------
|
|
382 |
// get Primary range
|
|
383 |
// ----------------------------------------------------------------------------
|
|
384 |
//
|
|
385 |
TInt CPeninputFingerHwrDataStore::PrimaryRange()
|
|
386 |
{
|
|
387 |
if( iPermittedRanges.Count() > 0 )
|
|
388 |
{
|
|
389 |
return iPermittedRanges[0];
|
|
390 |
}
|
|
391 |
return -1;
|
|
392 |
}
|
|
393 |
|
|
394 |
// ----------------------------------------------------------------------------
|
|
395 |
// get current range
|
|
396 |
// ----------------------------------------------------------------------------
|
|
397 |
//
|
|
398 |
TFingerHwrRange CPeninputFingerHwrDataStore::CurrentRange()
|
|
399 |
{
|
|
400 |
return iCurrentRange;
|
|
401 |
}
|
|
402 |
|
|
403 |
// ----------------------------------------------------------------------------
|
|
404 |
// Set case
|
|
405 |
// ----------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
void CPeninputFingerHwrDataStore::SetCase( TInt aCase )
|
|
408 |
{
|
|
409 |
iCase = aCase;
|
|
410 |
iHwrEngine->SetCase( iCase );
|
|
411 |
}
|
|
412 |
|
|
413 |
// ----------------------------------------------------------------------------
|
|
414 |
// Set language
|
|
415 |
// ----------------------------------------------------------------------------
|
|
416 |
//
|
|
417 |
void CPeninputFingerHwrDataStore::SetLanguageL( TInt aLanguage )
|
|
418 |
{
|
|
419 |
if( iLanguage == aLanguage )
|
|
420 |
{
|
|
421 |
return;
|
|
422 |
}
|
|
423 |
|
|
424 |
if ( !LanguageIsChinese( aLanguage ) && ( aLanguage != ELangEnglish ) )
|
|
425 |
{
|
|
426 |
return;
|
|
427 |
}
|
|
428 |
|
|
429 |
if ( aLanguage == ELangEnglish )
|
|
430 |
{
|
|
431 |
TLanguage displayLang = User::Language();
|
|
432 |
|
|
433 |
// set real language to a Chinese
|
|
434 |
if ( !LanguageIsChinese( iLanguage ) )
|
|
435 |
{
|
|
436 |
// original language is not Chinese
|
|
437 |
if ( LanguageIsChinese( displayLang ) )
|
|
438 |
{
|
|
439 |
iLanguage = displayLang;
|
|
440 |
}
|
|
441 |
else
|
|
442 |
{
|
|
443 |
iLanguage = ELangPrcChinese;
|
|
444 |
}
|
|
445 |
|
|
446 |
SetEngineLanguageL( iLanguage );
|
|
447 |
}
|
|
448 |
}
|
|
449 |
else
|
|
450 |
{
|
|
451 |
// aLanguage is Chinese
|
|
452 |
if ( iLanguage != aLanguage )
|
|
453 |
{
|
|
454 |
iLanguage = aLanguage;
|
|
455 |
|
|
456 |
SetEngineLanguageL( iLanguage );
|
|
457 |
}
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
// ----------------------------------------------------------------------------
|
|
462 |
// Set the candidate list
|
|
463 |
// ----------------------------------------------------------------------------
|
|
464 |
//
|
|
465 |
void CPeninputFingerHwrDataStore::SetCandidatesL()
|
|
466 |
{
|
|
467 |
if( !IsDirectlySentCandidate( *iCandidates[0] ) )
|
|
468 |
{
|
|
469 |
iTriggerStr->Set( *iCandidates[0] );
|
|
470 |
|
|
471 |
DoPredictiveL();
|
|
472 |
}
|
|
473 |
else
|
|
474 |
{
|
|
475 |
iTriggerStr->DeleteAll();
|
|
476 |
SetFixChinesePredictiveL();
|
|
477 |
}
|
|
478 |
}
|
|
479 |
|
|
480 |
// ----------------------------------------------------------------------------
|
|
481 |
// Set the candidate list
|
|
482 |
// ----------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
void CPeninputFingerHwrDataStore::SetAutoCompleteCandidatesL()
|
|
485 |
{
|
|
486 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
487 |
//those special chars: backspace and enter char need sent to
|
|
488 |
//app directly, not need to display candidate window
|
|
489 |
if ( iCandidates.Count()<1 || !iCandidates[0] )
|
|
490 |
{
|
|
491 |
return;
|
|
492 |
}
|
|
493 |
|
|
494 |
if ( !IsDirectlySentCandidate( *iCandidates[0] ) )
|
|
495 |
{
|
|
496 |
TPtrC string = iTriggerStr->GetString();
|
|
497 |
if(FirstStroke())
|
|
498 |
{
|
|
499 |
if(string.Length() == 0 ||
|
|
500 |
(string.Length() != 0 && !IsEnglishLetter(string.Right(1))))
|
|
501 |
{
|
|
502 |
// reset trigger string when got a punctuation
|
|
503 |
iLayout->SubmitStartPosToFep(ETrue);
|
|
504 |
iTriggerStr->Set( *iCandidates[0] );
|
|
505 |
}
|
|
506 |
else
|
|
507 |
{
|
|
508 |
// just add the new stroke to trigger string,
|
|
509 |
// when write a new char
|
|
510 |
iTriggerStr->Append( *iCandidates[0] );
|
|
511 |
}
|
|
512 |
}
|
|
513 |
else
|
|
514 |
{
|
|
515 |
// replace previous stroke
|
|
516 |
iTriggerStr->DeleteLast();
|
|
517 |
iTriggerStr->Append( *iCandidates[0] );
|
|
518 |
}
|
|
519 |
DoPredictiveL();
|
|
520 |
}
|
|
521 |
#endif
|
|
522 |
}
|
|
523 |
|
|
524 |
// ----------------------------------------------------------------------------
|
|
525 |
// Get first stroke flag
|
|
526 |
// ----------------------------------------------------------------------------
|
|
527 |
//
|
|
528 |
TBool CPeninputFingerHwrDataStore::FirstStroke()
|
|
529 |
{
|
|
530 |
return iIsFirstStroke;
|
|
531 |
}
|
|
532 |
|
|
533 |
// ----------------------------------------------------------------------------
|
|
534 |
// Set first stroke flag
|
|
535 |
// ----------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
void CPeninputFingerHwrDataStore::SetFirstStroke(const TBool aIsFirstStroke)
|
|
538 |
{
|
|
539 |
iIsFirstStroke = aIsFirstStroke;
|
|
540 |
}
|
|
541 |
|
|
542 |
// ----------------------------------------------------------------------------
|
|
543 |
// Get the candidate
|
|
544 |
// ----------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
const RPointerArray<HBufC>& CPeninputFingerHwrDataStore::Candidate() const
|
|
547 |
{
|
|
548 |
return iCandidates;
|
|
549 |
}
|
|
550 |
|
|
551 |
// ----------------------------------------------------------------------------
|
|
552 |
// Get the predictive
|
|
553 |
// ----------------------------------------------------------------------------
|
|
554 |
//
|
|
555 |
const RPointerArray<HBufC>& CPeninputFingerHwrDataStore::Predictive()
|
|
556 |
{
|
|
557 |
return iPredictives;
|
|
558 |
}
|
|
559 |
|
|
560 |
// ----------------------------------------------------------------------------
|
|
561 |
// Set number mode for hwr engine
|
|
562 |
// ----------------------------------------------------------------------------
|
|
563 |
//
|
|
564 |
void CPeninputFingerHwrDataStore::SetNumberMode(
|
|
565 |
const TAknEditorNumericKeymap aNumberMode )
|
|
566 |
{
|
|
567 |
iCurrentNumberMode = aNumberMode;
|
|
568 |
iHwrEngine->SetNumberMode( aNumberMode );
|
|
569 |
iHwrEngine->SetRanges( iPermittedRanges );
|
|
570 |
}
|
|
571 |
|
|
572 |
// ----------------------------------------------------------------------------
|
|
573 |
// Set number mode for hwr engine
|
|
574 |
// ----------------------------------------------------------------------------
|
|
575 |
//
|
|
576 |
void CPeninputFingerHwrDataStore::SetCustomNumberModeL( const TDesC& aCustomMode )
|
|
577 |
{
|
|
578 |
iHwrEngine->SetCustomKeymapL( aCustomMode );
|
|
579 |
|
|
580 |
delete iUserDefinedResource;
|
|
581 |
iUserDefinedResource = NULL;
|
|
582 |
iUserDefinedResource = HBufC::NewL( aCustomMode.Length() );
|
|
583 |
iUserDefinedResource->Des().Append( aCustomMode );
|
|
584 |
}
|
|
585 |
|
|
586 |
// ----------------------------------------------------------------------------
|
|
587 |
// save range to repository if english or chinese
|
|
588 |
// ----------------------------------------------------------------------------
|
|
589 |
//
|
|
590 |
void CPeninputFingerHwrDataStore::SaveRange( TInt aRange )
|
|
591 |
{
|
|
592 |
if ( iRepositoryFep && ( aRange == ERangeNative || aRange == ERangeEnglish ) )
|
|
593 |
{
|
|
594 |
iRepositoryFep->Set( KAknFepLastUsedRange, aRange );
|
|
595 |
}
|
|
596 |
}
|
|
597 |
|
|
598 |
// ------------------------------------------------------------------
|
|
599 |
// Get next predictive candidate page
|
|
600 |
// -------------------------------------------------------------------
|
|
601 |
//
|
|
602 |
void CPeninputFingerHwrDataStore::GetNextPredictivePageL()
|
|
603 |
{
|
|
604 |
iHwrEngine->DoPredictiveL( KNullDesC, iPredictives, ETrue );
|
|
605 |
|
|
606 |
TInt predictCount = PredictiveCount();
|
|
607 |
if ( predictCount <= 0 )
|
|
608 |
{
|
|
609 |
SetFixChinesePredictiveL();
|
|
610 |
}
|
|
611 |
}
|
|
612 |
|
|
613 |
// ------------------------------------------------------------------
|
|
614 |
// sync stroke end mark of writingbox with hwr engine.
|
|
615 |
// -------------------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CPeninputFingerHwrDataStore::SetStrokeEndMark()
|
|
618 |
{
|
|
619 |
iLayout->SyncHwrStrokeEndMark( iHwrEngine->StrokeEndMark() );
|
|
620 |
}
|
|
621 |
|
|
622 |
// ----------------------------------------------------------------------------
|
|
623 |
// get stroke end mark from hwr engine
|
|
624 |
// ----------------------------------------------------------------------------
|
|
625 |
//
|
|
626 |
TPoint CPeninputFingerHwrDataStore::StrokeEndMark()
|
|
627 |
{
|
|
628 |
return iHwrEngine->StrokeEndMark();
|
|
629 |
}
|
|
630 |
|
|
631 |
// ----------------------------------------------------------------------------
|
|
632 |
// stroke end mark from control
|
|
633 |
// ----------------------------------------------------------------------------
|
|
634 |
//
|
|
635 |
TPoint CPeninputFingerHwrDataStore::StrokeEndMarkFromControl()
|
|
636 |
{
|
|
637 |
return TPoint( KDefaultStrokeEndMarkX, KDefaultStrokeEndMarkY );
|
|
638 |
}
|
|
639 |
|
|
640 |
// --------------------------------------------------------------------
|
|
641 |
// Get number keymapping string
|
|
642 |
// --------------------------------------------------------------------
|
|
643 |
//
|
|
644 |
HBufC* CPeninputFingerHwrDataStore::KeyMappingStringL() const
|
|
645 |
{
|
|
646 |
TLocale locale;
|
|
647 |
TBuf<KMaxNumericString> rs = KNumberString(); // copy "0123456789"
|
|
648 |
const TInt index = iKeyMappingIdList.Find( iCurrentNumberMode );
|
|
649 |
|
|
650 |
if ( !( iPermittedRanges.Count() == 1 && iPermittedRanges[0] == ERangeNumber ) )
|
|
651 |
{
|
|
652 |
rs.Append( *iDefaultNumberMapping ); //normal editor
|
|
653 |
}
|
|
654 |
else if ( iCurrentNumberMode == EKeymapFromResource )
|
|
655 |
{
|
|
656 |
rs.Append( *iUserDefinedResource );
|
|
657 |
}
|
|
658 |
else if ( index != KErrNotFound )
|
|
659 |
{
|
|
660 |
HBufC* buf = iKeyMappingStringList[index];
|
|
661 |
|
|
662 |
rs.Append( *buf );
|
|
663 |
|
|
664 |
if ( ( iCurrentNumberMode == EAknEditorCalculatorNumberModeKeymap ) ||
|
|
665 |
( iCurrentNumberMode == EAknEditorConverterNumberModeKeymap ) )
|
|
666 |
{
|
|
667 |
rs.Append( locale.DecimalSeparator() );
|
|
668 |
}
|
|
669 |
}
|
|
670 |
|
|
671 |
return rs.AllocL();
|
|
672 |
}
|
|
673 |
|
|
674 |
// ------------------------------------------------------------------------
|
|
675 |
// CPeninputFingerHwrDataStore::IsSpecialDisplayChars
|
|
676 |
// ------------------------------------------------------------------------
|
|
677 |
//
|
|
678 |
TBool CPeninputFingerHwrDataStore::IsSpecialDisplayChars( const TDesC& aChar ) const
|
|
679 |
{
|
|
680 |
if( aChar.Compare( KGestureEnter ) == 0
|
|
681 |
|| aChar.Compare( KDisplayBackspace ) == 0
|
|
682 |
|| aChar.Compare( KGestureSpace )== 0 )
|
|
683 |
{
|
|
684 |
return ETrue;
|
|
685 |
}
|
|
686 |
|
|
687 |
return EFalse;
|
|
688 |
}
|
|
689 |
|
|
690 |
// -----------------------------------------------------------------------------
|
|
691 |
// CPeninputFingerHwrDataStore::IsDirectlySentCandidate
|
|
692 |
// -----------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
TBool CPeninputFingerHwrDataStore::IsDirectlySentCandidate( const TDesC& aChar ) const
|
|
695 |
{
|
|
696 |
|
|
697 |
if( aChar.Compare( KGestureEnter ) == 0 ||
|
|
698 |
aChar.Compare( KDisplayBackspace ) == 0)
|
|
699 |
{
|
|
700 |
return ETrue;
|
|
701 |
}
|
|
702 |
|
|
703 |
return EFalse;
|
|
704 |
}
|
|
705 |
|
|
706 |
// ------------------------------------------------------------------------
|
|
707 |
// CPeninputFingerHwrDataStore::ConvertDisplayChars
|
|
708 |
// ------------------------------------------------------------------------
|
|
709 |
//
|
|
710 |
HBufC* CPeninputFingerHwrDataStore::ConvertDisplayChars( const TDesC& aChar ) const
|
|
711 |
{
|
|
712 |
HBufC* convertedCan = NULL;
|
|
713 |
TBuf<KSpecialConvertedCharCount> str;
|
|
714 |
if( aChar.Compare( KGestureEnter ) == 0 )
|
|
715 |
{
|
|
716 |
str.Append( EKeyEnter );
|
|
717 |
}
|
|
718 |
else if( aChar.Compare( KDisplayBackspace ) == 0 )
|
|
719 |
{
|
|
720 |
str.Append( EKeyBackspace );
|
|
721 |
}
|
|
722 |
else if( aChar.Compare( KGestureSpace )== 0 )
|
|
723 |
{
|
|
724 |
str.Append( EKeySpace );
|
|
725 |
}
|
|
726 |
|
|
727 |
if( str.Length() > 0 )
|
|
728 |
{
|
|
729 |
convertedCan = str.Alloc();
|
|
730 |
}
|
|
731 |
|
|
732 |
return convertedCan;
|
|
733 |
}
|
|
734 |
|
|
735 |
// -----------------------------------------------------------------------------
|
|
736 |
// CPeninputFingerHwrDataStore::StartCharacter
|
|
737 |
// -----------------------------------------------------------------------------
|
|
738 |
//
|
|
739 |
TBool CPeninputFingerHwrDataStore::StartCharacter()
|
|
740 |
{
|
|
741 |
return iStartCharacter;
|
|
742 |
}
|
|
743 |
|
|
744 |
// -----------------------------------------------------------------------------
|
|
745 |
// CPeninputFingerHwrDataStore::SetStartCharacter
|
|
746 |
// -----------------------------------------------------------------------------
|
|
747 |
//
|
|
748 |
void CPeninputFingerHwrDataStore::SetStartCharacter(const TBool aStartCharacter)
|
|
749 |
{
|
|
750 |
iStartCharacter = aStartCharacter;
|
|
751 |
}
|
|
752 |
|
|
753 |
// -----------------------------------------------------------------------------
|
|
754 |
// CPeninputFingerHwrDataStore::SetInputAreaSize
|
|
755 |
// -----------------------------------------------------------------------------
|
|
756 |
//
|
|
757 |
TInt CPeninputFingerHwrDataStore::SetInputAreaSize(TSize& aSize)
|
|
758 |
{
|
|
759 |
return iHwrEngine->SetInputAreaSize(aSize);
|
|
760 |
}
|
|
761 |
|
|
762 |
// -----------------------------------------------------------------------------
|
|
763 |
// CPeninputFingerHwrDataStore::SetScreenSize
|
|
764 |
// -----------------------------------------------------------------------------
|
|
765 |
//
|
|
766 |
TInt CPeninputFingerHwrDataStore::SetScreenSize(TSize& aSize)
|
|
767 |
{
|
|
768 |
return iHwrEngine->SetScreenSize(aSize);
|
|
769 |
}
|
|
770 |
|
|
771 |
// -----------------------------------------------------------------------------
|
|
772 |
// CPeninputFingerHwrDataStore::ClearPredictive
|
|
773 |
// -----------------------------------------------------------------------------
|
|
774 |
//
|
|
775 |
void CPeninputFingerHwrDataStore::ClearPredictive()
|
|
776 |
{
|
|
777 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
778 |
iPredictives.ResetAndDestroy();
|
|
779 |
#endif
|
|
780 |
}
|
|
781 |
|
|
782 |
// -----------------------------------------------------------------------------
|
|
783 |
// CPeninputFingerHwrDataStore::SetHighlight
|
|
784 |
// -----------------------------------------------------------------------------
|
|
785 |
//
|
|
786 |
void CPeninputFingerHwrDataStore::SetHighlight(const TBool aIsHighlight)
|
|
787 |
{
|
|
788 |
iIsHighlightCell = aIsHighlight;
|
|
789 |
}
|
|
790 |
|
|
791 |
// -----------------------------------------------------------------------------
|
|
792 |
// CPeninputFingerHwrDataStore::Highlight
|
|
793 |
// -----------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
TBool CPeninputFingerHwrDataStore::Highlight()
|
|
796 |
{
|
|
797 |
return iIsHighlightCell;
|
|
798 |
}
|
|
799 |
|
|
800 |
// -----------------------------------------------------------------------------
|
|
801 |
// CPeninputFingerHwrDataStore::RemoveDuplicateCand
|
|
802 |
// -----------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
TInt CPeninputFingerHwrDataStore::RemoveDuplicateCand(const RPointerArray<HBufC>& aSrc,
|
|
805 |
RPointerArray<HBufC>& aTgt,
|
|
806 |
TInt aSrcStartIdx,
|
|
807 |
TInt aTgtStartIdx)
|
|
808 |
{
|
|
809 |
TInt lastOverlapIdx = KInvalidIndex;
|
|
810 |
|
|
811 |
// on the assumption that if candidate overlap,
|
|
812 |
// it is overlap only once
|
|
813 |
TInt srccandcnt = aSrc.Count();
|
|
814 |
|
|
815 |
for (TInt i = aSrcStartIdx; i < srccandcnt; i++)
|
|
816 |
{
|
|
817 |
for (TInt j = aTgtStartIdx; j < aTgt.Count(); j++)
|
|
818 |
{
|
|
819 |
if (aTgt[j]->Compare(*(aSrc[i])) == 0)
|
|
820 |
{
|
|
821 |
lastOverlapIdx = i;
|
|
822 |
delete aTgt[j];
|
|
823 |
aTgt.Remove(j);
|
|
824 |
j--;
|
|
825 |
break;
|
|
826 |
}
|
|
827 |
}
|
|
828 |
}
|
|
829 |
|
|
830 |
return lastOverlapIdx;
|
|
831 |
}
|
|
832 |
|
|
833 |
// ----------------------------------------------------------------------------
|
|
834 |
// C++ constructor
|
|
835 |
// ----------------------------------------------------------------------------
|
|
836 |
//
|
|
837 |
CPeninputFingerHwrDataStore::CPeninputFingerHwrDataStore(CPeninputFingerHwrLayout* aLayout)
|
|
838 |
:iLayout( aLayout )
|
|
839 |
{
|
|
840 |
iLanguage = ELangNone;
|
|
841 |
iCurrentNumberMode = EAknEditorStandardNumberModeKeymap;
|
|
842 |
iIsHighlightCell = ETrue;
|
|
843 |
}
|
|
844 |
|
|
845 |
// ----------------------------------------------------------------------------
|
|
846 |
// Second phase constructor
|
|
847 |
// ----------------------------------------------------------------------------
|
|
848 |
//
|
|
849 |
void CPeninputFingerHwrDataStore::ConstructL( CPtiEngine* aPtiEngine )
|
|
850 |
{
|
|
851 |
//create the repository for fep settings
|
|
852 |
iRepositoryFep = CRepository::NewL( KCRUidAknFep );
|
|
853 |
|
|
854 |
//create the trigger string
|
|
855 |
iTriggerStr = new ( ELeave ) CAknFepHwrTriggerStr();
|
|
856 |
|
|
857 |
//create the hwr engine
|
|
858 |
iHwrEngine = CAknFepHwrEngine::NewL( aPtiEngine, this );
|
|
859 |
|
|
860 |
//initialize the key mapping list
|
|
861 |
InitKeyMappingListL();
|
|
862 |
}
|
|
863 |
|
|
864 |
// ----------------------------------------------------------------------------
|
|
865 |
// Initialize the key mapping list
|
|
866 |
// ----------------------------------------------------------------------------
|
|
867 |
//
|
|
868 |
void CPeninputFingerHwrDataStore::InitKeyMappingListL()
|
|
869 |
{
|
|
870 |
CCoeEnv* env = CCoeEnv::Static();
|
|
871 |
|
|
872 |
//read default key mapping string from resource
|
|
873 |
if ( iDefaultNumberMapping )
|
|
874 |
{
|
|
875 |
delete iDefaultNumberMapping;
|
|
876 |
iDefaultNumberMapping = NULL;
|
|
877 |
}
|
|
878 |
iDefaultNumberMapping = env->AllocReadResourceL( R_AKN_FEP_HWR_KEY_MAPPING_DEFAULT );
|
|
879 |
|
|
880 |
//read the key maping string from resource
|
|
881 |
TResourceReader reader;
|
|
882 |
env->CreateResourceReaderLC( reader, R_AKN_FEP_HWR_KEY_MAPPING_STRING_LIST );
|
|
883 |
|
|
884 |
const TInt count = reader.ReadInt16();
|
|
885 |
|
|
886 |
for ( TInt i = 0; i < count; i++ )
|
|
887 |
{
|
|
888 |
iKeyMappingIdList.Append( reader.ReadInt16() );
|
|
889 |
TPtrC ptr = reader.ReadTPtrC();
|
|
890 |
iKeyMappingStringList.Append( ptr.Alloc() );
|
|
891 |
}
|
|
892 |
iCurrentNumberMode = EAknEditorStandardNumberModeKeymap;
|
|
893 |
|
|
894 |
CleanupStack::PopAndDestroy(); //reader
|
|
895 |
}
|
|
896 |
|
|
897 |
// ----------------------------------------------------------------------------
|
|
898 |
// Judge if a language is Chinese
|
|
899 |
// ----------------------------------------------------------------------------
|
|
900 |
//
|
|
901 |
TBool CPeninputFingerHwrDataStore::LanguageIsChinese( TInt aLanguage )
|
|
902 |
{
|
|
903 |
if ( ( aLanguage == ELangPrcChinese ) ||
|
|
904 |
( aLanguage == ELangHongKongChinese ) ||
|
|
905 |
( aLanguage == ELangTaiwanChinese ) )
|
|
906 |
{
|
|
907 |
return ETrue;
|
|
908 |
}
|
|
909 |
|
|
910 |
return EFalse;
|
|
911 |
}
|
|
912 |
|
|
913 |
// ----------------------------------------------------------------------------
|
|
914 |
// Set real engine language
|
|
915 |
// ----------------------------------------------------------------------------
|
|
916 |
//
|
|
917 |
void CPeninputFingerHwrDataStore::SetEngineLanguageL( TInt aLanguage )
|
|
918 |
{
|
|
919 |
SetLanguageShowText( aLanguage );
|
|
920 |
iHwrEngine->SetLanguageL( aLanguage );
|
|
921 |
iHwrEngine->SetPrimaryCandidateNum( KCandidateCount );
|
|
922 |
}
|
|
923 |
|
|
924 |
// ----------------------------------------------------------------------------
|
|
925 |
// Set language show text
|
|
926 |
// ----------------------------------------------------------------------------
|
|
927 |
//
|
|
928 |
void CPeninputFingerHwrDataStore::SetLanguageShowText( TInt aLanguage )
|
|
929 |
{
|
|
930 |
AknPenInputUtils::GetISOLanguageCode( TLanguage( aLanguage ),
|
|
931 |
iLanguageShowText );
|
|
932 |
}
|
|
933 |
|
|
934 |
// ----------------------------------------------------------------------------
|
|
935 |
// Remove accent characters
|
|
936 |
// ----------------------------------------------------------------------------
|
|
937 |
//
|
|
938 |
void CPeninputFingerHwrDataStore::RemoveAccent()
|
|
939 |
{
|
|
940 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
941 |
if(TriggerStr()->GetString().Length() != 1)
|
|
942 |
{
|
|
943 |
return;
|
|
944 |
}
|
|
945 |
|
|
946 |
TInt count = PredictiveCount();
|
|
947 |
for(TInt i = count; i > 0; i--)
|
|
948 |
{
|
|
949 |
if(!IsEnglishLetter(iPredictives[i - 1]->Des()))
|
|
950 |
{
|
|
951 |
delete iPredictives[i-1];
|
|
952 |
iPredictives.Remove(i-1);
|
|
953 |
count--;
|
|
954 |
}
|
|
955 |
}
|
|
956 |
|
|
957 |
#endif
|
|
958 |
}
|
|
959 |
|
|
960 |
// ----------------------------------------------------------------------------
|
|
961 |
// Reset key board type
|
|
962 |
// ----------------------------------------------------------------------------
|
|
963 |
//
|
|
964 |
void CPeninputFingerHwrDataStore::ResetKeyboardType()
|
|
965 |
{
|
|
966 |
iHwrEngine->ResetKeyboardType();
|
|
967 |
}
|
|
968 |
|
|
969 |
// ----------------------------------------------------------------------------
|
|
970 |
// Set key board type to Qwerty
|
|
971 |
// ----------------------------------------------------------------------------
|
|
972 |
//
|
|
973 |
void CPeninputFingerHwrDataStore::SetKeyboardToQwerty()
|
|
974 |
{
|
|
975 |
iHwrEngine->SetKeyboardToQwerty();
|
|
976 |
}
|
|
977 |
|
|
978 |
// ----------------------------------------------------------------------------
|
|
979 |
// Get key board type
|
|
980 |
// ----------------------------------------------------------------------------
|
|
981 |
//
|
|
982 |
void CPeninputFingerHwrDataStore::GetKeyboardType()
|
|
983 |
{
|
|
984 |
iHwrEngine->GetKeyboardType();
|
|
985 |
}
|
|
986 |
|
|
987 |
// End Of File
|