44
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2005 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 of candidate base chinese phrase state
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
#include "AknFepUiInputStateCandidateBaseChinesePhrase.h"
|
|
30 |
#include "AknFepUiCtrlContainerChinese.h"
|
|
31 |
#include "AknFepUICtrlCandidatePane.h"
|
|
32 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
33 |
#include "AknFepManagerUIInterface.h"
|
|
34 |
#include "AknFepManager.h" //FepMan flag
|
|
35 |
|
|
36 |
#include "AknFepUICtrlInputPane.h"
|
|
37 |
#include "AknFepUICtrlPinyinPopup.h"
|
|
38 |
#include <PtiEngine.h> //CPtiEngine
|
|
39 |
|
|
40 |
#include <aknnotewrappers.h> //CAknInformationNote
|
|
41 |
|
|
42 |
#include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase
|
|
43 |
#include "aknfepuictrleditpane.h" //pinyin phrase creation
|
|
44 |
#include "aknfepzhuyinconvertion.h"
|
|
45 |
#include "aknfepzhuyinkeyhandlerinterface.h"
|
|
46 |
#include "AknFepZhuyinAnalyserDb.h"
|
|
47 |
#include "AknFepZhuyinAnalyser.h"
|
|
48 |
|
|
49 |
_LIT( KPinyinListSeparator, "'" );
|
|
50 |
_LIT( KPinyinStar, "*" );
|
|
51 |
_LIT( KPinyinTone0ValidStr, "\x02C9");
|
|
52 |
_LIT( KPinyinTone1ValidStr, "\x02CA");
|
|
53 |
_LIT( KPinyinTone2ValidStr, "\x02C7");
|
|
54 |
_LIT( KPinyinTone3ValidStr, "\x02CB");
|
|
55 |
_LIT( KPinyinTone4ValidStr, "\x02D9");
|
|
56 |
|
|
57 |
const TText KPinyinTone0Valid = 0x02C9;
|
|
58 |
const TText KPinyinTone1Valid = 0x02CA;
|
|
59 |
const TText KPinyinTone2Valid = 0x02C7;
|
|
60 |
const TText KPinyinTone3Valid = 0x02CB;
|
|
61 |
const TText KPinyinTone4Valid = 0x02D9;
|
|
62 |
const TInt KKey0Code = 48;
|
|
63 |
const TInt KKey2Code = 50;
|
|
64 |
const TInt KKey3Code = 51;
|
|
65 |
const TInt KKey4Code = 52;
|
|
66 |
const TInt KKey5Code = 53;
|
|
67 |
const TInt KKey6Code = 54;
|
|
68 |
const TInt KKey7Code = 55;
|
|
69 |
const TInt KKey8Code = 56;
|
|
70 |
const TInt KKey9Code = 57;
|
|
71 |
|
|
72 |
const TInt KMaxKeystrokeCount = 100;
|
|
73 |
const TInt KMaxPinyinLength = 60;
|
|
74 |
|
|
75 |
const TInt KStarCount1 = 1;
|
|
76 |
const TInt KStarCount2 = 2;
|
|
77 |
const TInt KStarCount3 = 3;
|
|
78 |
const TInt KStarCount4 = 4;
|
|
79 |
const TInt KStarCount5 = 5;
|
|
80 |
|
|
81 |
const TUint16 KSegment = 0x0020;
|
|
82 |
|
|
83 |
_LIT( KKey0Num, "0");
|
|
84 |
_LIT( KKey1Num, "1");
|
|
85 |
_LIT( KKey2Num, "2");
|
|
86 |
_LIT( KKey3Num, "3");
|
|
87 |
_LIT( KKey4Num, "4");
|
|
88 |
_LIT( KKey5Num, "5");
|
|
89 |
_LIT( KKey6Num, "6");
|
|
90 |
_LIT( KKey7Num, "7");
|
|
91 |
_LIT( KKey8Num, "8");
|
|
92 |
_LIT( KKey9Num, "9");
|
|
93 |
_LIT( KPinyinSysSeparator, "\x002E");
|
|
94 |
|
|
95 |
TAknFepInputStateCandidateBaseChinesePhrase::TAknFepInputStateCandidateBaseChinesePhrase(
|
|
96 |
MAknFepUIManagerStateInterface* aOwner,
|
|
97 |
MAknFepUICtrlContainerChinese* aUIContainer)
|
|
98 |
:TAknFepInputStateCandidateBase(aOwner, aUIContainer)
|
|
99 |
{
|
|
100 |
}
|
|
101 |
|
|
102 |
void TAknFepInputStateCandidateBaseChinesePhrase::HandleCommandL(
|
|
103 |
TInt aCommandId )
|
|
104 |
{
|
|
105 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
106 |
// it may be one of the 'valid' numbers..
|
|
107 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
108 |
UIContainer()->CandidatePane();
|
|
109 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
110 |
TPtrC text = candidatePane->CurrentPhraseCandidate();
|
|
111 |
switch ( aCommandId )
|
|
112 |
{
|
|
113 |
// Handle the event frome command.
|
|
114 |
case EAknSoftkeyCancel:
|
|
115 |
// case (TUint16)EAknSoftkeyCancel: //the Cancle in soft CBA
|
|
116 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
117 |
break;
|
|
118 |
case EAknSoftkeySelect:
|
|
119 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
|
|
120 |
HandleCommitL();
|
|
121 |
break;
|
|
122 |
default:
|
|
123 |
TAknFepInputStateCandidateBase::HandleCommandL( aCommandId );
|
|
124 |
break;
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::HandleKeyL( TInt aKey,
|
|
129 |
TKeyPressLength aLength )
|
|
130 |
{
|
|
131 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
132 |
if ( aKey == EPtiKeyStar )
|
|
133 |
{
|
|
134 |
if ( fepMan->IsEnableKeyStar() )
|
|
135 |
{
|
|
136 |
iOwner->FepMan()->TryCloseUiL();
|
|
137 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
138 |
return EFalse;
|
|
139 |
}
|
|
140 |
else
|
|
141 |
{
|
|
142 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
143 |
return ETrue;
|
|
144 |
}
|
|
145 |
}
|
|
146 |
if ( !(HandleVerticalNavigation( aKey, aLength )
|
|
147 |
|| HandleHorizontalNavigation( aKey )) )
|
|
148 |
{
|
|
149 |
// it may be one of the 'valid' numbers..
|
|
150 |
TInt index = MapKeyToIndex( aKey );
|
|
151 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
152 |
UIContainer()->CandidatePane();
|
|
153 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
154 |
|
|
155 |
TBool state = ETrue;
|
|
156 |
if ( popup->IsChangeStatet() && aLength == ELongKeyPress )
|
|
157 |
{
|
|
158 |
state = EFalse;
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
popup->SetChangeState( EFalse );
|
|
163 |
}
|
|
164 |
if ( state )
|
|
165 |
{
|
|
166 |
if ( candidatePane->SelectIndex( index, EFalse ) || aKey
|
|
167 |
== EKeyOK || aKey == EKeyCBA1 )
|
|
168 |
{
|
|
169 |
HandleCommitL();
|
|
170 |
}
|
|
171 |
}
|
|
172 |
}
|
|
173 |
return ETrue;
|
|
174 |
}
|
|
175 |
|
|
176 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::HandleHorizontalNavigation(TInt aKey)
|
|
177 |
{
|
|
178 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
179 |
TBool response = EFalse;
|
|
180 |
|
|
181 |
// Do navigation...
|
|
182 |
if (aKey == EKeyLeftArrow)
|
|
183 |
{
|
|
184 |
// if (candidatePane->SelectedIndex() == 0 &&
|
|
185 |
// candidatePane->IsFirstPage() )
|
|
186 |
// {
|
|
187 |
// return ETrue;
|
|
188 |
// }
|
|
189 |
|
|
190 |
if(!candidatePane->SelectPrev())
|
|
191 |
{
|
|
192 |
// candidatePane->PreviousCandidatePage();
|
|
193 |
candidatePane->SetCandidateBuffer();
|
|
194 |
candidatePane->SelectLastPhrase();
|
|
195 |
}
|
|
196 |
response = ETrue;
|
|
197 |
}
|
|
198 |
else if (aKey == EKeyRightArrow)
|
|
199 |
{
|
|
200 |
// if (candidatePane->IsLastPage() &&
|
|
201 |
// (candidatePane->SelectedIndex() == candidatePane->VisibleCandidateCount() - 1))
|
|
202 |
// {
|
|
203 |
// return ETrue;
|
|
204 |
// }
|
|
205 |
|
|
206 |
if(!candidatePane->SelectNext())
|
|
207 |
{
|
|
208 |
// candidatePane->NextCandidatePage();
|
|
209 |
candidatePane->SetCandidateBuffer();
|
|
210 |
candidatePane->SelectFirstPhrase();
|
|
211 |
}
|
|
212 |
response = ETrue;
|
|
213 |
}
|
|
214 |
|
|
215 |
if (response)
|
|
216 |
{
|
|
217 |
UpdateIndicator();
|
|
218 |
}
|
|
219 |
|
|
220 |
return response;
|
|
221 |
}
|
|
222 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::HandleVerticalNavigation(TInt aKey)
|
|
223 |
{
|
|
224 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
225 |
MZhuyinKeyHandler* zhuyinKeyHandler = iOwner->ZhuyinKeyHandler();
|
|
226 |
|
|
227 |
if (aKey == EKeyDownArrow)
|
|
228 |
{
|
|
229 |
if (candidatePane->IsLastPage())
|
|
230 |
{
|
|
231 |
return ETrue;
|
|
232 |
}
|
|
233 |
if ( iState != EPredictiveCandidate &&
|
|
234 |
iState != EPredictiveInput )
|
|
235 |
{
|
|
236 |
if (candidatePane->NeedGetNewCandidatePage() )
|
|
237 |
{
|
|
238 |
if ( !iOwner->PtiEngine()->NextCandidatePage() )
|
|
239 |
{
|
|
240 |
if ( candidatePane->IsLastPage() )
|
|
241 |
{
|
|
242 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
243 |
return ETrue;
|
|
244 |
}
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
CDesCArrayFlat* phraseCandidates =
|
|
249 |
candidatePane->CandidateArray();
|
|
250 |
RPointerArray<HBufC> list;
|
|
251 |
TRAP_IGNORE(
|
|
252 |
GetNewCandidatesL(iOwner->PtiEngine()->CandidatePage(), list);
|
|
253 |
for (TInt i = 0; i < list.Count(); ++i)
|
|
254 |
{
|
|
255 |
phraseCandidates->AppendL( *(list[i]));
|
|
256 |
}
|
|
257 |
list.ResetAndDestroy(););
|
|
258 |
}
|
|
259 |
}
|
|
260 |
}
|
|
261 |
candidatePane->NextCandidatePage();
|
|
262 |
}
|
|
263 |
else if (aKey == EKeyUpArrow)
|
|
264 |
{
|
|
265 |
if ( candidatePane->IsFirstPage() && iState != EPredictiveCandidate )
|
|
266 |
{
|
|
267 |
zhuyinKeyHandler->SetState(0);
|
|
268 |
iOwner->ChangeState(EZhuyinSequenceEdit);
|
|
269 |
return EFalse;
|
|
270 |
}
|
|
271 |
else if ( candidatePane->IsFirstPage() )
|
|
272 |
{
|
|
273 |
return ETrue;
|
|
274 |
}
|
|
275 |
candidatePane->PreviousCandidatePage();
|
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
return EFalse;
|
|
280 |
}
|
|
281 |
candidatePane->SetCandidateBuffer();
|
|
282 |
candidatePane->SelectFirstPhrase();
|
|
283 |
UpdateIndicator();
|
|
284 |
return ETrue;
|
|
285 |
}
|
|
286 |
|
|
287 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::HandleVerticalNavigation(TInt aKey, TKeyPressLength aLength)
|
|
288 |
{
|
|
289 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
290 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
291 |
|
|
292 |
if (aKey == EKeyDownArrow)
|
|
293 |
{
|
|
294 |
TBool state = ETrue;
|
|
295 |
if ( popup->IsChangeStatet() && aLength == ELongKeyPress )
|
|
296 |
{
|
|
297 |
state = EFalse;
|
|
298 |
}
|
|
299 |
else
|
|
300 |
{
|
|
301 |
popup->SetChangeState( EFalse );
|
|
302 |
}
|
|
303 |
if ( state )
|
|
304 |
{
|
|
305 |
if (candidatePane->IsLastPage())
|
|
306 |
{
|
|
307 |
return ETrue;
|
|
308 |
}
|
|
309 |
if ( iState != EPredictiveCandidate &&
|
|
310 |
iState != EPredictiveInput )
|
|
311 |
{
|
|
312 |
if (candidatePane->NeedGetNewCandidatePage() )
|
|
313 |
{
|
|
314 |
if ( !iOwner->PtiEngine()->NextCandidatePage( ) )
|
|
315 |
{
|
|
316 |
if ( candidatePane->IsLastPage() )
|
|
317 |
{
|
|
318 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
319 |
return ETrue;
|
|
320 |
}
|
|
321 |
}
|
|
322 |
else
|
|
323 |
{
|
|
324 |
CDesCArrayFlat* phraseCandidates =
|
|
325 |
candidatePane->CandidateArray( );
|
|
326 |
RPointerArray<HBufC> list;
|
|
327 |
TRAP_IGNORE(
|
|
328 |
GetNewCandidatesL( iOwner->PtiEngine()->CandidatePage( ), list );
|
|
329 |
for (TInt i = 0; i < list.Count( ); ++i )
|
|
330 |
{
|
|
331 |
phraseCandidates->AppendL( *(list[i]) );
|
|
332 |
}
|
|
333 |
list.ResetAndDestroy(););
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
337 |
candidatePane->NextCandidatePage();
|
|
338 |
}
|
|
339 |
}
|
|
340 |
else if (aKey == EKeyUpArrow)
|
|
341 |
{
|
|
342 |
if (candidatePane->IsFirstPage() )
|
|
343 |
{
|
|
344 |
return ETrue;
|
|
345 |
}
|
|
346 |
candidatePane->PreviousCandidatePage();
|
|
347 |
}
|
|
348 |
else
|
|
349 |
{
|
|
350 |
return EFalse;
|
|
351 |
}
|
|
352 |
candidatePane->SetCandidateBuffer();
|
|
353 |
candidatePane->SelectFirstPhrase();
|
|
354 |
UpdateIndicator();
|
|
355 |
return ETrue;
|
|
356 |
}
|
|
357 |
|
|
358 |
void TAknFepInputStateCandidateBaseChinesePhrase::UpdateIndicator()
|
|
359 |
{
|
|
360 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
361 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
362 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
363 |
|
|
364 |
if (candidatePane->IsFirstPage())
|
|
365 |
{
|
|
366 |
uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);
|
|
367 |
}
|
|
368 |
else
|
|
369 |
{
|
|
370 |
uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);
|
|
371 |
}
|
|
372 |
|
|
373 |
if (candidatePane->IsLastPage())
|
|
374 |
{
|
|
375 |
uiContainer->CandidatePane()->ShowDownScrollArrows(EFalse);
|
|
376 |
}
|
|
377 |
else
|
|
378 |
{
|
|
379 |
uiContainer->CandidatePane()->ShowDownScrollArrows(ETrue);
|
|
380 |
}
|
|
381 |
}
|
|
382 |
|
|
383 |
// ---------------------------------------------------------
|
|
384 |
// get the valid keystroke
|
|
385 |
// ---------------------------------------------------------
|
|
386 |
//
|
|
387 |
void TAknFepInputStateCandidateBaseChinesePhrase::GetValidkeystrokeL( )
|
|
388 |
{
|
|
389 |
TInt keyCode;
|
|
390 |
TInt stringBeforeLength = 0;
|
|
391 |
TInt stringAfterLength = 0;
|
|
392 |
TBuf<1> keystroke;
|
|
393 |
TBuf<1> keystrokeTmp;
|
|
394 |
|
|
395 |
CPtiEngine* ptiengine = iOwner->PtiEngine( );
|
|
396 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer( );
|
|
397 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow( );
|
|
398 |
|
|
399 |
CDesCArrayFlat* keystrokeArray = popup->KeystrokeArray( );
|
|
400 |
CDesCArrayFlat* inEffectKeystrokeArray = popup->InEffectKeystrokeArray( );
|
|
401 |
|
|
402 |
inEffectKeystrokeArray->Reset( );
|
|
403 |
inEffectKeystrokeArray->Compress( );
|
|
404 |
|
|
405 |
for (TInt i = 0; i < keystrokeArray->Count( ); ++i )
|
|
406 |
{
|
|
407 |
stringBeforeLength = 0;
|
|
408 |
stringAfterLength = 0;
|
|
409 |
keystroke.Copy( keystrokeArray->MdcaPoint( i ) );
|
|
410 |
if ( 0 == i )
|
|
411 |
{
|
|
412 |
if ( ( 0 == keystroke.Compare( KPinyinStar ) ) || ( 0
|
|
413 |
== keystroke.Compare( KPinyinListSeparator ) ) )
|
|
414 |
{
|
|
415 |
return;
|
|
416 |
}
|
|
417 |
}
|
|
418 |
else
|
|
419 |
{
|
|
420 |
keystrokeTmp.Copy( keystrokeArray->MdcaPoint( i - 1 ) );
|
|
421 |
if ( 0 == keystroke.Compare( KPinyinListSeparator ) )
|
|
422 |
{
|
|
423 |
if ( ( 0 != keystrokeTmp.Compare( KPinyinListSeparator ) )
|
|
424 |
&& ( 0 != keystrokeTmp.Compare( KPinyinStar ) ) )
|
|
425 |
{
|
|
426 |
inEffectKeystrokeArray->AppendL( keystroke );
|
|
427 |
}
|
|
428 |
return;
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
if ( i >= 1 )
|
|
433 |
{
|
|
434 |
keystrokeTmp.Copy( keystrokeArray->MdcaPoint( i - 1 ) );
|
|
435 |
if ( ( 0 == keystroke.Compare( KPinyinStar ) ) && ( 0
|
|
436 |
== keystrokeTmp.Compare( KPinyinStar ) ) )
|
|
437 |
{
|
|
438 |
inEffectKeystrokeArray->AppendL( keystroke );
|
|
439 |
ptiengine->IncrementToneMark( ETrue );
|
|
440 |
}
|
|
441 |
else if ( ( 0 != keystrokeTmp.Compare( KPinyinStar ) ) && ( 0
|
|
442 |
== keystroke.Compare( KPinyinStar ) ) )
|
|
443 |
{
|
|
444 |
inEffectKeystrokeArray->AppendL( keystroke );
|
|
445 |
ptiengine->IncrementToneMark( ETrue );
|
|
446 |
}
|
|
447 |
else if ( ( 0 != keystroke.Compare( KPinyinStar ) ) && ( 0
|
|
448 |
== keystrokeTmp.Compare( KPinyinStar ) ) )
|
|
449 |
{
|
|
450 |
if ( !CheckSpellingOfPtiEngine( ) )
|
|
451 |
{
|
|
452 |
ptiengine->DeleteKeyPress( );
|
|
453 |
DeleteTonMarkFromInEffectKeytrokeArray( );
|
|
454 |
}
|
|
455 |
return;
|
|
456 |
}
|
|
457 |
}
|
|
458 |
|
|
459 |
if ( 0 != keystroke.Compare( KPinyinStar ) )
|
|
460 |
{
|
|
461 |
|
|
462 |
inEffectKeystrokeArray->AppendL( keystrokeArray->MdcaPoint( i ) );
|
|
463 |
GetKeystrokeCode( keyCode, keystroke );
|
|
464 |
stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length( );
|
|
465 |
stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)keyCode).Length( );
|
|
466 |
if ( stringBeforeLength == stringAfterLength )
|
|
467 |
{
|
|
468 |
inEffectKeystrokeArray->Delete( inEffectKeystrokeArray->Count( )
|
|
469 |
- 1 );
|
|
470 |
inEffectKeystrokeArray->Compress( );
|
|
471 |
return;
|
|
472 |
}
|
|
473 |
if ( 0 == keystroke.Compare( KPinyinListSeparator ) )
|
|
474 |
{
|
|
475 |
return;
|
|
476 |
}
|
|
477 |
|
|
478 |
if ( !CheckSpellingOfPtiEngine( ) )
|
|
479 |
{
|
|
480 |
ptiengine->DeleteKeyPress( );
|
|
481 |
inEffectKeystrokeArray->Delete( i );
|
|
482 |
return;
|
|
483 |
}
|
|
484 |
}
|
|
485 |
else
|
|
486 |
{
|
|
487 |
if ( i == keystrokeArray->Count( ) - 1 )
|
|
488 |
{
|
|
489 |
if ( !CheckSpellingOfPtiEngine( ) )
|
|
490 |
{
|
|
491 |
ptiengine->DeleteKeyPress( );
|
|
492 |
DeleteTonMarkFromInEffectKeytrokeArray( );
|
|
493 |
return;
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
// ---------------------------------------------------------
|
|
501 |
// Check the Spelling of PtiEngine.
|
|
502 |
// ---------------------------------------------------------
|
|
503 |
//
|
|
504 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::CheckSpellingOfPtiEngine( )
|
|
505 |
{
|
|
506 |
CPtiEngine* ptiengine = iOwner->PtiEngine( );
|
|
507 |
TInt count = ptiengine->PhoneticSpellingCount( );
|
|
508 |
|
|
509 |
for (TInt i = 1; i <= count; ++i )
|
|
510 |
{
|
|
511 |
TPtrC spelling = ptiengine->GetPhoneticSpelling( i );
|
|
512 |
if ( KErrNotFound == spelling.Find( KPinyinListSeparator ) )
|
|
513 |
{
|
|
514 |
return ETrue;
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
return EFalse;
|
|
519 |
}
|
|
520 |
|
|
521 |
void TAknFepInputStateCandidateBaseChinesePhrase::GetKeystrokeCode(
|
|
522 |
TInt& aKey, const TDesC& aKeystroke )
|
|
523 |
{
|
|
524 |
if ( 0 == aKeystroke.Compare( KKey0Num ) )
|
|
525 |
{
|
|
526 |
aKey = KKey0Code;
|
|
527 |
}
|
|
528 |
else if ( 0 == aKeystroke.Compare( KKey1Num ) )
|
|
529 |
{
|
|
530 |
aKey = KKey0Code;
|
|
531 |
}
|
|
532 |
else if ( 0 == aKeystroke.Compare( KKey2Num ) )
|
|
533 |
{
|
|
534 |
aKey = KKey2Code;
|
|
535 |
}
|
|
536 |
else if ( 0 == aKeystroke.Compare( KKey3Num ) )
|
|
537 |
{
|
|
538 |
aKey = KKey3Code;
|
|
539 |
}
|
|
540 |
else if ( 0 == aKeystroke.Compare( KKey4Num ) )
|
|
541 |
{
|
|
542 |
aKey = KKey4Code;
|
|
543 |
}
|
|
544 |
else if ( 0 == aKeystroke.Compare( KKey5Num ) )
|
|
545 |
{
|
|
546 |
aKey = KKey5Code;
|
|
547 |
}
|
|
548 |
else if ( 0 == aKeystroke.Compare( KKey6Num ) )
|
|
549 |
{
|
|
550 |
aKey = KKey6Code;
|
|
551 |
}
|
|
552 |
else if ( 0 == aKeystroke.Compare( KKey7Num ) )
|
|
553 |
{
|
|
554 |
aKey = KKey7Code;
|
|
555 |
}
|
|
556 |
else if ( 0 == aKeystroke.Compare( KKey8Num ) )
|
|
557 |
{
|
|
558 |
aKey = KKey8Code;
|
|
559 |
}
|
|
560 |
else if ( 0 == aKeystroke.Compare( KKey9Num ) )
|
|
561 |
{
|
|
562 |
aKey = KKey9Code;
|
|
563 |
}
|
|
564 |
else if ( 0 == aKeystroke.Compare( KPinyinListSeparator ) )
|
|
565 |
{
|
|
566 |
aKey = KKey0Code;
|
|
567 |
}
|
|
568 |
|
|
569 |
}
|
|
570 |
// ---------------------------------------------------------
|
|
571 |
// clear the ptiengine keystroke;
|
|
572 |
// ---------------------------------------------------------
|
|
573 |
//
|
|
574 |
void TAknFepInputStateCandidateBaseChinesePhrase::ClearPtiEngineKeystroke( )
|
|
575 |
{
|
|
576 |
CDesCArrayFlat* inEffectKeystrokeArray = UIContainer()->PinyinPopupWindow()->InEffectKeystrokeArray( );
|
|
577 |
|
|
578 |
for (TInt i = 0; i < KMaxKeystrokeCount; ++i )
|
|
579 |
{
|
|
580 |
iOwner->PtiEngine()->DeleteKeyPress( );
|
|
581 |
}
|
|
582 |
inEffectKeystrokeArray->Reset( );
|
|
583 |
inEffectKeystrokeArray->Compress( );
|
|
584 |
}
|
|
585 |
|
|
586 |
// ---------------------------------------------------------
|
|
587 |
// delete tonmark from in effect keystroke array
|
|
588 |
// ---------------------------------------------------------
|
|
589 |
//
|
|
590 |
void TAknFepInputStateCandidateBaseChinesePhrase::DeleteTonMarkFromInEffectKeytrokeArray( )
|
|
591 |
{
|
|
592 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
593 |
CDesCArrayFlat* inEffectKeystrokeArray = popup->InEffectKeystrokeArray();
|
|
594 |
TInt count = inEffectKeystrokeArray->Count() - 1;
|
|
595 |
TInt checkCount = 0;
|
|
596 |
for ( TInt i = count; i > 0 ; i-- )
|
|
597 |
{
|
|
598 |
if ( 0 == inEffectKeystrokeArray->MdcaPoint( i ).Compare( KPinyinStar ) )
|
|
599 |
{
|
|
600 |
inEffectKeystrokeArray->Delete( i );
|
|
601 |
inEffectKeystrokeArray->Compress();
|
|
602 |
checkCount = checkCount + 1;
|
|
603 |
}
|
|
604 |
else
|
|
605 |
{
|
|
606 |
break;
|
|
607 |
}
|
|
608 |
}
|
|
609 |
|
|
610 |
if ( checkCount > 0 )
|
|
611 |
{
|
|
612 |
if ( inEffectKeystrokeArray->Count() > 0 )
|
|
613 |
{
|
|
614 |
inEffectKeystrokeArray->Delete( inEffectKeystrokeArray->Count() -1 );
|
|
615 |
}
|
|
616 |
iOwner->PtiEngine()->DeleteKeyPress();
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
// ---------------------------------------------------------
|
|
621 |
// get the valid keystroke
|
|
622 |
// ---------------------------------------------------------
|
|
623 |
//
|
|
624 |
void TAknFepInputStateCandidateBaseChinesePhrase::CheckTonemarkL( )
|
|
625 |
{
|
|
626 |
CPtiEngine* ptiengine = iOwner->PtiEngine( );
|
|
627 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow( );
|
|
628 |
CDesCArrayFlat* inEffectKeystrokeArray = popup->InEffectKeystrokeArray( );
|
|
629 |
CDesCArrayFlat* spelling = popup->OptimizeSpelling( );
|
|
630 |
|
|
631 |
TInt keystrokeStarCount = 0;
|
|
632 |
TInt validSpellCount = 0;
|
|
633 |
TInt i = 0;
|
|
634 |
TBuf<1> buf;
|
|
635 |
|
|
636 |
TBuf<1> lastSpellTonemark;
|
|
637 |
TBuf<1> tonmarkBuf0;
|
|
638 |
TBuf<1> tonmarkBuf1;
|
|
639 |
TBuf<1> tonmarkBuf2;
|
|
640 |
TBuf<1> tonmarkBuf3;
|
|
641 |
TBuf<1> tonmarkBuf4;
|
|
642 |
TBuf<KMaxPinyinLength> spellBuf;
|
|
643 |
tonmarkBuf0.Append( KPinyinTone0Valid );
|
|
644 |
tonmarkBuf1.Append( KPinyinTone1Valid );
|
|
645 |
tonmarkBuf2.Append( KPinyinTone2Valid );
|
|
646 |
tonmarkBuf3.Append( KPinyinTone3Valid );
|
|
647 |
tonmarkBuf4.Append( KPinyinTone4Valid );
|
|
648 |
|
|
649 |
if ( 0 == inEffectKeystrokeArray->Count( ) )
|
|
650 |
{
|
|
651 |
return;
|
|
652 |
}
|
|
653 |
|
|
654 |
for (i = inEffectKeystrokeArray->Count( ) - 1; i >= 0; i-- )
|
|
655 |
{
|
|
656 |
if ( 0 == inEffectKeystrokeArray->MdcaPoint( i ).Compare( KPinyinStar ) )
|
|
657 |
{
|
|
658 |
keystrokeStarCount = keystrokeStarCount + 1;
|
|
659 |
}
|
|
660 |
else
|
|
661 |
{
|
|
662 |
break;
|
|
663 |
}
|
|
664 |
}
|
|
665 |
|
|
666 |
if ( 0 == keystrokeStarCount )
|
|
667 |
{
|
|
668 |
return;
|
|
669 |
}
|
|
670 |
|
|
671 |
switch ( keystrokeStarCount )
|
|
672 |
{
|
|
673 |
case KStarCount1:
|
|
674 |
buf.Copy( tonmarkBuf0 );
|
|
675 |
break;
|
|
676 |
case KStarCount2:
|
|
677 |
buf.Copy( tonmarkBuf1 );
|
|
678 |
break;
|
|
679 |
case KStarCount3:
|
|
680 |
buf.Copy( tonmarkBuf2 );
|
|
681 |
break;
|
|
682 |
case KStarCount4:
|
|
683 |
buf.Copy( tonmarkBuf3 );
|
|
684 |
break;
|
|
685 |
case KStarCount5:
|
|
686 |
buf.Copy( tonmarkBuf4 );
|
|
687 |
break;
|
|
688 |
default:
|
|
689 |
break;
|
|
690 |
}
|
|
691 |
|
|
692 |
spelling->Reset( );
|
|
693 |
spelling->Compress( );
|
|
694 |
|
|
695 |
ptiengine->GetPhoneticSpellingsL( *spelling );
|
|
696 |
|
|
697 |
for (i = 0; i < spelling->Count( ); ++i )
|
|
698 |
{
|
|
699 |
spellBuf.Copy( spelling->MdcaPoint( i ) );
|
|
700 |
TInt position = spellBuf.Find( KPinyinListSeparator );
|
|
701 |
if ( KErrNotFound == position )
|
|
702 |
{
|
|
703 |
lastSpellTonemark.Copy( spellBuf.Mid( spellBuf.Length( ) - 1, 1 ) );
|
|
704 |
if ( 0 == lastSpellTonemark.Compare( buf ) )
|
|
705 |
{
|
|
706 |
validSpellCount = 1;
|
|
707 |
break;
|
|
708 |
}
|
|
709 |
}
|
|
710 |
}
|
|
711 |
|
|
712 |
spelling->Reset( );
|
|
713 |
spelling->Compress( );
|
|
714 |
|
|
715 |
if ( validSpellCount > 0 )
|
|
716 |
{
|
|
717 |
return;
|
|
718 |
}
|
|
719 |
|
|
720 |
for (i = 0; i < keystrokeStarCount; ++i )
|
|
721 |
{
|
|
722 |
inEffectKeystrokeArray->Delete( inEffectKeystrokeArray->Count( ) -1 );
|
|
723 |
}
|
|
724 |
|
|
725 |
ptiengine->DeleteKeyPress( );
|
|
726 |
|
|
727 |
if ( inEffectKeystrokeArray->Count( ) > 0 )
|
|
728 |
{
|
|
729 |
inEffectKeystrokeArray->Delete( inEffectKeystrokeArray->Count( ) - 1 );
|
|
730 |
}
|
|
731 |
inEffectKeystrokeArray->Compress( );
|
|
732 |
|
|
733 |
ptiengine->DeleteKeyPress( );
|
|
734 |
|
|
735 |
while (inEffectKeystrokeArray->Count( ) > 0 )
|
|
736 |
{
|
|
737 |
spelling->Reset( );
|
|
738 |
spelling->Compress( );
|
|
739 |
ptiengine->GetPhoneticSpellingsL( *spelling );
|
|
740 |
|
|
741 |
for (i = 0; i < spelling->Count( ); ++i )
|
|
742 |
{
|
|
743 |
if ( KErrNotFound == spelling->MdcaPoint( i ).Find( KPinyinListSeparator ) )
|
|
744 |
{
|
|
745 |
spelling->Reset( );
|
|
746 |
spelling->Compress( );
|
|
747 |
return;
|
|
748 |
}
|
|
749 |
}
|
|
750 |
ptiengine->DeleteKeyPress( );
|
|
751 |
inEffectKeystrokeArray->Delete( inEffectKeystrokeArray->Count( ) - 1 );
|
|
752 |
}
|
|
753 |
|
|
754 |
spelling->Reset( );
|
|
755 |
spelling->Compress( );
|
|
756 |
}
|
|
757 |
|
|
758 |
TBool TAknFepInputStateCandidateBaseChinesePhrase::IsValid( const TDesC& aDesC, TInt aCount )
|
|
759 |
{
|
|
760 |
TBool lastIsToneMark = EFalse;
|
|
761 |
TBool ret = ETrue;
|
|
762 |
TInt charCount = aCount;
|
|
763 |
for ( TInt i = 0; i < aDesC.Length(); i++ )
|
|
764 |
{
|
|
765 |
if ( ( aDesC.Mid( i, 1 ) == KPinyinSysSeparator ) ||
|
|
766 |
( aDesC.Mid( i, 1 ) == KPinyinListSeparator ) ||
|
|
767 |
( *aDesC.Mid( i , 1 ).Ptr() == KPinyinTone0Valid ) ||
|
|
768 |
( *aDesC.Mid( i , 1 ).Ptr() == KPinyinTone1Valid ) ||
|
|
769 |
( *aDesC.Mid( i , 1 ).Ptr() == KPinyinTone2Valid ) ||
|
|
770 |
( *aDesC.Mid( i , 1 ).Ptr() == KPinyinTone3Valid ) ||
|
|
771 |
( *aDesC.Mid( i , 1 ).Ptr() == KPinyinTone4Valid ) )
|
|
772 |
{
|
|
773 |
if ( lastIsToneMark && charCount <= 0 )
|
|
774 |
{
|
|
775 |
ret = EFalse;
|
|
776 |
}
|
|
777 |
lastIsToneMark = ETrue;
|
|
778 |
charCount--;
|
|
779 |
}
|
|
780 |
else
|
|
781 |
{
|
|
782 |
lastIsToneMark = EFalse;
|
|
783 |
}
|
|
784 |
}
|
|
785 |
return ret;
|
|
786 |
}
|
|
787 |
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
// TAknFepInputStateCandidateBaseChinesePhrase::HandleCommitL
|
|
790 |
// Handle CBA1 or select event.
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
//
|
|
793 |
void TAknFepInputStateCandidateBaseChinesePhrase::HandleCommitL()
|
|
794 |
{
|
|
795 |
// it may be one of the 'valid' numbers..
|
|
796 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
797 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
798 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
799 |
UIContainer()->CandidatePane();
|
|
800 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
801 |
TPtrC text = candidatePane->CurrentPhraseCandidate();
|
|
802 |
if ( text.Length() )
|
|
803 |
{
|
|
804 |
//commit and show char in editor
|
|
805 |
if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
|
|
806 |
{
|
|
807 |
fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
|
|
808 |
iOwner->FepMan()->TryCloseUiL();
|
|
809 |
}
|
|
810 |
else
|
|
811 |
{
|
|
812 |
TInt i = 0;
|
|
813 |
CDesCArrayFlat* keystroke =
|
|
814 |
UIContainer()->PinyinPopupWindow()->KeystrokeArray();
|
|
815 |
if ( keystroke->Count() != 0 && keystroke->Count()
|
|
816 |
> text.Length() )
|
|
817 |
{
|
|
818 |
TBuf<KMaxKeystrokeCount> seq;
|
|
819 |
for (i = 0; i < keystroke->Count(); ++i )
|
|
820 |
{
|
|
821 |
seq.Append( keystroke->MdcaPoint( i ) );
|
|
822 |
}
|
|
823 |
TInt count = 0;
|
|
824 |
|
|
825 |
TBufC<KMaxKeystrokeCount> buf1;
|
|
826 |
TPtr ptr1 = buf1.Des();
|
|
827 |
TBufC<KMaxKeystrokeCount> keyseqBuf;
|
|
828 |
TPtr ptr2 = keyseqBuf.Des();
|
|
829 |
TBuf<KMaxKeystrokeCount> ptr2Left;
|
|
830 |
ptr2.Copy( seq );
|
|
831 |
if ( ptiengine->SelectedPhoneticSpelling() == 1 )
|
|
832 |
{
|
|
833 |
ptr1 = ptiengine->GetPhoneticSpelling(1);
|
|
834 |
}
|
|
835 |
else
|
|
836 |
{
|
|
837 |
UIContainer()->InputPane()->GetText( ptr1 );
|
|
838 |
}
|
|
839 |
TInt pos = 0;
|
|
840 |
TInt len = 0;
|
|
841 |
|
|
842 |
CDesCArray
|
|
843 |
* chineseCharacterArrayKeystroke =
|
|
844 |
UIContainer()->PinyinPopupWindow()->ChooseChineseCharacterArrayKeystroke();
|
|
845 |
chineseCharacterArrayKeystroke->Reset();
|
|
846 |
for (i = 0; i < ptr1.Length() && count < text.Length()
|
|
847 |
&& ptr2.Length() != 0; i++ )
|
|
848 |
{
|
|
849 |
if ( ptr1.Mid( i, 1 ) == KPinyinSysSeparator ||
|
|
850 |
ptr1.Mid( i, 1 ) == KPinyinListSeparator )
|
|
851 |
{
|
|
852 |
pos = i - len - count;
|
|
853 |
if ( pos < 0 )
|
|
854 |
{
|
|
855 |
pos = 0;
|
|
856 |
}
|
|
857 |
|
|
858 |
if ( pos == ptr2.Length() )
|
|
859 |
{
|
|
860 |
pos = ptr2.Length() - 1;
|
|
861 |
}
|
|
862 |
|
|
863 |
if ( ptr2.Mid( pos, 1 ) == KPinyinListSeparator )
|
|
864 |
{
|
|
865 |
i++;
|
|
866 |
pos += 1;
|
|
867 |
chineseCharacterArrayKeystroke->AppendL(
|
|
868 |
ptr2.Left( pos ) );
|
|
869 |
ptr2 = ptr2.Mid( pos );
|
|
870 |
}
|
|
871 |
else
|
|
872 |
{
|
|
873 |
chineseCharacterArrayKeystroke->AppendL(
|
|
874 |
ptr2.Left( pos ) );
|
|
875 |
ptr2 = ptr2.Mid( pos );
|
|
876 |
}
|
|
877 |
len += pos;
|
|
878 |
count++;
|
|
879 |
}
|
|
880 |
else if ( *ptr1.Mid( i, 1 ).Ptr() == KPinyinTone0Valid )
|
|
881 |
{
|
|
882 |
pos = i + 1 - len - count;
|
|
883 |
len += pos;
|
|
884 |
ptr2Left.Zero();
|
|
885 |
ptr2Left.Copy( ptr2.Left( pos - 1 ) );
|
|
886 |
ptr2Left.Append( KPinyinTone0ValidStr );
|
|
887 |
chineseCharacterArrayKeystroke->AppendL( ptr2Left );
|
|
888 |
ptr2 = ptr2.Mid( pos );
|
|
889 |
count++;
|
|
890 |
}
|
|
891 |
else if ( *ptr1.Mid( i, 1 ).Ptr() == KPinyinTone1Valid )
|
|
892 |
{
|
|
893 |
pos = i + 2 - len - count;
|
|
894 |
len += pos - 1;
|
|
895 |
ptr2Left.Zero();
|
|
896 |
ptr2Left.Copy( ptr2.Left( pos - 2 ) );
|
|
897 |
ptr2Left.Append( KPinyinTone1ValidStr );
|
|
898 |
chineseCharacterArrayKeystroke->AppendL( ptr2Left );
|
|
899 |
ptr2 = ptr2.Mid( pos );
|
|
900 |
count++;
|
|
901 |
}
|
|
902 |
else if ( *ptr1.Mid( i, 1 ).Ptr() == KPinyinTone2Valid )
|
|
903 |
{
|
|
904 |
pos = i + 3 - len - count;
|
|
905 |
len += pos - 2;
|
|
906 |
ptr2Left.Zero();
|
|
907 |
ptr2Left.Copy( ptr2.Left( pos - 3 ) );
|
|
908 |
ptr2Left.Append( KPinyinTone2ValidStr );
|
|
909 |
chineseCharacterArrayKeystroke->AppendL( ptr2Left );
|
|
910 |
ptr2 = ptr2.Mid( pos );
|
|
911 |
count++;
|
|
912 |
}
|
|
913 |
else if ( *ptr1.Mid( i, 1 ).Ptr() == KPinyinTone3Valid )
|
|
914 |
{
|
|
915 |
pos = i + 4 - len - count;
|
|
916 |
len += pos - 3;
|
|
917 |
ptr2Left.Zero();
|
|
918 |
ptr2Left.Copy( ptr2.Left( pos - 4 ) );
|
|
919 |
ptr2Left.Append( KPinyinTone3ValidStr );
|
|
920 |
chineseCharacterArrayKeystroke->AppendL( ptr2Left );
|
|
921 |
ptr2 = ptr2.Mid( pos );
|
|
922 |
count++;
|
|
923 |
}
|
|
924 |
else if ( *ptr1.Mid( i, 1 ).Ptr() == KPinyinTone4Valid )
|
|
925 |
{
|
|
926 |
pos = i + 5 - len - count;
|
|
927 |
len += pos - 4;
|
|
928 |
ptr2Left.Zero();
|
|
929 |
ptr2Left.Copy( ptr2.Left( pos - 5 ) );
|
|
930 |
ptr2Left.Append( KPinyinTone4ValidStr );
|
|
931 |
chineseCharacterArrayKeystroke->AppendL( ptr2Left );
|
|
932 |
ptr2 = ptr2.Mid( pos );
|
|
933 |
count++;
|
|
934 |
}
|
|
935 |
}
|
|
936 |
|
|
937 |
TInt totalCount = 0;
|
|
938 |
for (i = 0; i < ptr1.Length(); i++ )
|
|
939 |
{
|
|
940 |
if ( (ptr1.Mid( i, 1 ) == KPinyinSysSeparator)
|
|
941 |
|| (ptr1.Mid( i, 1 ) == KPinyinListSeparator)
|
|
942 |
|| (*ptr1.Mid( i, 1 ).Ptr() == KPinyinTone0Valid)
|
|
943 |
|| (*ptr1.Mid( i, 1 ).Ptr() == KPinyinTone1Valid)
|
|
944 |
|| (*ptr1.Mid( i, 1 ).Ptr() == KPinyinTone2Valid)
|
|
945 |
|| (*ptr1.Mid( i, 1 ).Ptr() == KPinyinTone3Valid)
|
|
946 |
|| (*ptr1.Mid( i, 1 ).Ptr() == KPinyinTone4Valid) )
|
|
947 |
{
|
|
948 |
totalCount++;
|
|
949 |
}
|
|
950 |
}
|
|
951 |
|
|
952 |
if ( !((ptr1.Right( 1 ) == KPinyinListSeparator)
|
|
953 |
|| (*ptr1.Right( 1 ).Ptr() == KPinyinTone0Valid)
|
|
954 |
|| (*ptr1.Right( 1 ).Ptr() == KPinyinTone1Valid)
|
|
955 |
|| (*ptr1.Right( 1 ).Ptr() == KPinyinTone2Valid)
|
|
956 |
|| (*ptr1.Right( 1 ).Ptr() == KPinyinTone3Valid)
|
|
957 |
|| (*ptr1.Right( 1 ).Ptr() == KPinyinTone4Valid)) )
|
|
958 |
{
|
|
959 |
totalCount++;
|
|
960 |
}
|
|
961 |
|
|
962 |
if ( totalCount > text.Length() )//pinyin group more than phrase,will create phrase
|
|
963 |
{
|
|
964 |
CDesCArray* chineseCharacterArray =//phrase
|
|
965 |
UIContainer()->PinyinPopupWindow()->ChooseChineseCharacterArray();
|
|
966 |
chineseCharacterArray->Reset();
|
|
967 |
|
|
968 |
CDesCArray* chineseCharacterArraySpelling =//phrase spelling
|
|
969 |
UIContainer()->PinyinPopupWindow()->ChooseChineseCharacterArraySpelling();
|
|
970 |
chineseCharacterArraySpelling->Reset();
|
|
971 |
|
|
972 |
TBuf<KMaxKeystrokeCount> buf = ptr1;
|
|
973 |
for (i = 0; i < text.Length(); i++ )//usually,if totalCount > text.Length()then text length is 1
|
|
974 |
{
|
|
975 |
|
|
976 |
//here,store spelling,ptr1 is full spelling
|
|
977 |
TInt separatorIdx = KErrNotFound;
|
|
978 |
if(KErrNotFound == separatorIdx)
|
|
979 |
separatorIdx = buf.Find(KPinyinSysSeparator);
|
|
980 |
if(KErrNotFound == separatorIdx)
|
|
981 |
separatorIdx = buf.Find(KPinyinListSeparator);
|
|
982 |
if(KErrNotFound == separatorIdx)
|
|
983 |
separatorIdx = buf.Find(KPinyinTone0ValidStr);
|
|
984 |
if(KErrNotFound == separatorIdx)
|
|
985 |
separatorIdx = buf.Find(KPinyinTone1ValidStr);
|
|
986 |
if(KErrNotFound == separatorIdx)
|
|
987 |
separatorIdx = buf.Find(KPinyinTone2ValidStr);
|
|
988 |
if(KErrNotFound == separatorIdx)
|
|
989 |
separatorIdx = buf.Find(KPinyinTone3ValidStr);
|
|
990 |
if(KErrNotFound == separatorIdx)
|
|
991 |
separatorIdx = buf.Find(KPinyinTone4ValidStr);
|
|
992 |
|
|
993 |
if(separatorIdx == KErrNotFound )
|
|
994 |
{
|
|
995 |
if(buf.Length()>0)//only one
|
|
996 |
{
|
|
997 |
chineseCharacterArraySpelling->AppendL(buf);
|
|
998 |
buf.Zero();
|
|
999 |
}
|
|
1000 |
}
|
|
1001 |
else
|
|
1002 |
{
|
|
1003 |
chineseCharacterArraySpelling->AppendL(buf.Left(separatorIdx+1));//include separator and tone mark
|
|
1004 |
buf.Delete(0,separatorIdx+1);
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
chineseCharacterArray->AppendL( text.Mid( i, 1 ) );
|
|
1008 |
}
|
|
1009 |
|
|
1010 |
|
|
1011 |
//set key stroke
|
|
1012 |
CDesCArray* keyStroke =
|
|
1013 |
UIContainer()->PinyinPopupWindow()->KeystrokeArray();
|
|
1014 |
keyStroke->Reset();
|
|
1015 |
for (i = 0; i < ptr2.Length(); i++ )
|
|
1016 |
{
|
|
1017 |
keyStroke->AppendL( ptr2.Mid( i, 1 ) );
|
|
1018 |
}
|
|
1019 |
//set show stroke
|
|
1020 |
CDesCArray* showStroke =
|
|
1021 |
UIContainer()->PinyinPopupWindow()->ShowKeystrokeArray();
|
|
1022 |
showStroke->Reset();
|
|
1023 |
TInt pinyinStarCount = 0;
|
|
1024 |
for (i = 0; i < ptr2.Length(); )
|
|
1025 |
{
|
|
1026 |
pinyinStarCount = 0;
|
|
1027 |
if ( ptr2.Mid( i, 1 ) == KPinyinStar )
|
|
1028 |
{
|
|
1029 |
while (i < ptr2.Length() && ptr2.Mid( i, 1 )
|
|
1030 |
== KPinyinStar )
|
|
1031 |
{
|
|
1032 |
pinyinStarCount++;
|
|
1033 |
i++;
|
|
1034 |
}
|
|
1035 |
switch ( pinyinStarCount )
|
|
1036 |
{
|
|
1037 |
case 1:
|
|
1038 |
showStroke->AppendL( KPinyinTone0ValidStr );
|
|
1039 |
break;
|
|
1040 |
case 2:
|
|
1041 |
showStroke->AppendL( KPinyinTone1ValidStr );
|
|
1042 |
break;
|
|
1043 |
case 3:
|
|
1044 |
showStroke->AppendL( KPinyinTone2ValidStr );
|
|
1045 |
break;
|
|
1046 |
case 4:
|
|
1047 |
showStroke->AppendL( KPinyinTone3ValidStr );
|
|
1048 |
break;
|
|
1049 |
case 5:
|
|
1050 |
showStroke->AppendL( KPinyinTone4ValidStr );
|
|
1051 |
break;
|
|
1052 |
default:
|
|
1053 |
break;
|
|
1054 |
}
|
|
1055 |
}
|
|
1056 |
else
|
|
1057 |
{
|
|
1058 |
showStroke->AppendL( ptr2.Mid( i, 1 ) );
|
|
1059 |
i++;
|
|
1060 |
}
|
|
1061 |
}
|
|
1062 |
fepMan->PinyinPhraseCreation( ETrue );
|
|
1063 |
ClearPtiEngineKeystroke();
|
|
1064 |
GetValidkeystrokeL();
|
|
1065 |
CheckTonemarkL();
|
|
1066 |
|
|
1067 |
CDesCArrayFlat* inEffectKeystrokeArray =
|
|
1068 |
popup->InEffectKeystrokeArray();
|
|
1069 |
|
|
1070 |
if ( inEffectKeystrokeArray->Count() == 0 || !IsValid(
|
|
1071 |
ptr1, text.Length() ) )
|
|
1072 |
{
|
|
1073 |
UIContainer()->SetControlInVisible( EFalse );
|
|
1074 |
popup->SetPhraseCreationState( ETrue );
|
|
1075 |
iOwner->ChangeState( EKeySequenceEdit );
|
|
1076 |
}
|
|
1077 |
else
|
|
1078 |
{
|
|
1079 |
popup->SetPhraseCreationState( ETrue );
|
|
1080 |
iOwner->ChangeState( ESpellingSelection );
|
|
1081 |
}
|
|
1082 |
}
|
|
1083 |
else
|
|
1084 |
{
|
|
1085 |
CDesCArray* keyStroke =
|
|
1086 |
UIContainer()->PinyinPopupWindow()->KeystrokeArray();
|
|
1087 |
keyStroke->Reset();
|
|
1088 |
//commit and show char in editor
|
|
1089 |
fepMan->NewTextL( text );
|
|
1090 |
fepMan->CommitInlineEditL();
|
|
1091 |
fepMan->PinyinPhraseCreation( EFalse );
|
|
1092 |
if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
|
|
1093 |
{
|
|
1094 |
fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
|
|
1095 |
iOwner->FepMan()->TryCloseUiL();
|
|
1096 |
}
|
|
1097 |
else
|
|
1098 |
{
|
|
1099 |
iOwner->ChangeState( EPredictiveCandidate );
|
|
1100 |
}
|
|
1101 |
}
|
|
1102 |
}
|
|
1103 |
else
|
|
1104 |
{
|
|
1105 |
CDesCArray* keyStroke =
|
|
1106 |
UIContainer()->PinyinPopupWindow()->KeystrokeArray();
|
|
1107 |
keyStroke->Reset();
|
|
1108 |
//commit and show char in editor
|
|
1109 |
fepMan->NewTextL( text );
|
|
1110 |
fepMan->CommitInlineEditL();
|
|
1111 |
fepMan->PinyinPhraseCreation( EFalse );
|
|
1112 |
if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
|
|
1113 |
{
|
|
1114 |
fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
|
|
1115 |
iOwner->FepMan()->TryCloseUiL();
|
|
1116 |
}
|
|
1117 |
else
|
|
1118 |
{
|
|
1119 |
iOwner->ChangeState( EPredictiveCandidate );
|
|
1120 |
}
|
|
1121 |
}
|
|
1122 |
}
|
|
1123 |
}
|
|
1124 |
else
|
|
1125 |
{
|
|
1126 |
// No candidates available. Back to Entry state.
|
|
1127 |
iOwner->ChangeState( EEntry );
|
|
1128 |
}
|
|
1129 |
}
|
|
1130 |
|
|
1131 |
void TAknFepInputStateCandidateBaseChinesePhrase::GetNewCandidatesL(const TDesC& aSource,
|
|
1132 |
RPointerArray<HBufC>& aList)
|
|
1133 |
{
|
|
1134 |
TInt start = 0;
|
|
1135 |
TInt length = 0;
|
|
1136 |
|
|
1137 |
for (TInt ii = 0; ii < aSource.Length(); ii++)
|
|
1138 |
{
|
|
1139 |
if (aSource[ii] == KSegment)
|
|
1140 |
{
|
|
1141 |
TPtrC segment(aSource.Ptr() + start, length);
|
|
1142 |
aList.AppendL(segment.AllocL());
|
|
1143 |
start += (length + 1);
|
|
1144 |
length = 0;
|
|
1145 |
}
|
|
1146 |
else
|
|
1147 |
{
|
|
1148 |
length++;
|
|
1149 |
}
|
|
1150 |
}
|
|
1151 |
|
|
1152 |
if (length)
|
|
1153 |
{
|
|
1154 |
TPtrC segm(aSource.Ptr() + start, length);
|
|
1155 |
aList.AppendL(segm.AllocL());
|
|
1156 |
}
|
|
1157 |
}
|
|
1158 |
// End of file
|