119 {0x02C7, 3}, |
119 {0x02C7, 3}, |
120 {0x02CB, 4}, |
120 {0x02CB, 4}, |
121 {0x02D9, 5} |
121 {0x02D9, 5} |
122 }; |
122 }; |
123 |
123 |
124 const TUid KPtiSogouCoreUid = { 0x20031DD6 }; |
|
125 |
|
126 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
127 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
125 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
128 // C++ default constructor |
126 // C++ default constructor |
129 // --------------------------------------------------------------------------- |
127 // --------------------------------------------------------------------------- |
130 // |
128 // |
139 } |
137 } |
140 iOwner->PtiEngine()->SetCandidatePageLength(KMaxPhraseCount); |
138 iOwner->PtiEngine()->SetCandidatePageLength(KMaxPhraseCount); |
141 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
139 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
142 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage()); |
140 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage()); |
143 uiContainer->ShowVerticalScrollArrows(multiplePages); |
141 uiContainer->ShowVerticalScrollArrows(multiplePages); |
144 |
|
145 // If sogou core is in use, set plugin to the state |
|
146 // machine and enable the plugin. |
|
147 // Get current core id. It is used to judge whether sogou core is in use. |
|
148 TInt coreID = 0; |
|
149 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
150 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
151 { |
|
152 TAknFepInputMiniQwertySogouPinyinPhrasePlugin plugin( aOwner, aUIContainer, iState ); |
|
153 plugin.Enable( ETrue ); |
|
154 SetPlugin( plugin ); |
|
155 } |
|
156 } |
142 } |
157 |
143 |
158 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
159 // TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL |
145 // TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL |
160 // Handle system key press event. |
146 // Handle system key press event. |
398 { |
384 { |
399 return EFalse; |
385 return EFalse; |
400 } |
386 } |
401 } |
387 } |
402 GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) ); |
388 GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) ); |
403 |
389 stringBeforeLength = getCurrentLeastDLTSpell().Length(); |
404 // dltBeforeCount is the dlt count before append the key. |
|
405 // dltAfterCount is the dlt count after append the key. |
|
406 // In sogou core, after appending a new key, the spell length |
|
407 // may be the same, but the dlt count will change. |
|
408 // In this situation, the appended key is valid. |
|
409 TInt dltBeforeCount = 0; |
|
410 TInt dltAfterCount = 0; |
|
411 TPtrC stringBefore = getCurrentLeastDLTSpell(); |
|
412 stringBeforeLength = stringBefore.Length(); |
|
413 for ( TInt k = 0; k < stringBefore.Length(); k++ ) |
|
414 { |
|
415 if ( CheckSpellingDLT( stringBefore.Mid( k ))) |
|
416 { |
|
417 dltBeforeCount++; |
|
418 } |
|
419 } |
|
420 |
|
421 // Append the key. |
|
422 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
390 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
423 |
391 stringAfterLength = getCurrentLeastDLTSpell().Length(); |
424 // Get the dlt count after appending the key. |
392 //the keystroke is invalid. |
425 TPtrC stringAfter = getCurrentLeastDLTSpell(); |
393 if (stringBeforeLength == stringAfterLength) |
426 stringAfterLength = stringAfter.Length(); |
|
427 for ( TInt l = 0; l < stringAfter.Length(); l++ ) |
|
428 { |
|
429 if ( CheckSpellingDLT( stringAfter.Mid( l ))) |
|
430 { |
|
431 dltAfterCount++; |
|
432 } |
|
433 } |
|
434 |
|
435 // If the spell length is the same and the dlt count is |
|
436 // the same, the keystroke is invalid |
|
437 if (( stringBeforeLength == stringAfterLength ) && |
|
438 ( dltAfterCount == dltBeforeCount )) |
|
439 { |
394 { |
440 return EFalse; |
395 return EFalse; |
441 } |
396 } |
442 } |
397 } |
443 return ETrue; |
398 return ETrue; |
458 TInt index = editPane->GetCursorIndexOfKeystroke(); |
413 TInt index = editPane->GetCursorIndexOfKeystroke(); |
459 TInt pos = 0; |
414 TInt pos = 0; |
460 TInt count = 0; |
415 TInt count = 0; |
461 TBuf<1> autoDLT; |
416 TBuf<1> autoDLT; |
462 autoDLT.Append(KAutoDLT); |
417 autoDLT.Append(KAutoDLT); |
463 |
418 |
464 // If this method is called in construction of the state machine, |
|
465 // the plugin is not set. If sogou core is in use now, the phraseCount |
|
466 // should be the same as the phrase characters count. |
|
467 // For Sogou core, maybe one element of PhraseArray() contains two or more characters. |
|
468 TInt coreID = 0; |
|
469 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
470 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
471 { |
|
472 CDesCArrayFlat* phraseArray = editPane->PhraseArray(); |
|
473 phraseCount = 0; |
|
474 for ( TInt i = 0; i < phraseArray->Count(); i++ ) |
|
475 { |
|
476 phraseCount += (*phraseArray)[i].Length(); |
|
477 } |
|
478 } |
|
479 |
|
480 if ( 0 == index) |
419 if ( 0 == index) |
481 { |
420 { |
482 pos = phraseCount; |
421 pos = phraseCount; |
483 } |
422 } |
484 else |
423 else |
576 TBuf<1> manualDLT; |
515 TBuf<1> manualDLT; |
577 TBuf<1> autoDLT; |
516 TBuf<1> autoDLT; |
578 manualDLT.Append( KManualDLT ); |
517 manualDLT.Append( KManualDLT ); |
579 autoDLT.Append( KAutoDLT ); |
518 autoDLT.Append( KAutoDLT ); |
580 |
519 |
581 // Get the current core id |
|
582 TInt coreID = 0; |
|
583 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
584 |
|
585 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
586 { |
|
587 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
588 phraseCount = 0; |
|
589 for ( TInt j = 0; j < phrase->Count(); j++ ) |
|
590 { |
|
591 phraseCount += phrase->MdcaPoint(j).Length();; |
|
592 } |
|
593 } |
|
594 |
|
595 if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount ) |
|
596 { |
|
597 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
598 return; |
|
599 } |
|
600 |
|
601 TBool firstGroup = CheckFirstGroupStroke(); |
520 TBool firstGroup = CheckFirstGroupStroke(); |
602 |
521 |
603 keystrokeArray->InsertL(index, manualDLT); |
522 keystrokeArray->InsertL(index, manualDLT); |
604 editPane->SetCursorIndexOfKeystroke(index + 1); |
523 editPane->SetCursorIndexOfKeystroke(index + 1); |
605 AnalyseL(); |
524 AnalyseL(); |
952 // Analyse key storke. |
871 // Analyse key storke. |
953 // --------------------------------------------------------------------------- |
872 // --------------------------------------------------------------------------- |
954 // |
873 // |
955 void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseL() |
874 void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseL() |
956 { |
875 { |
957 // If sogou core is actived, use the plugin. |
|
958 if ( iPlugin.IsEnable()) |
|
959 { |
|
960 iPlugin.AnalyseL(); |
|
961 return; |
|
962 } |
|
963 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
876 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
964 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
877 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
965 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
878 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
966 //user pressed keystroke sequence |
879 //user pressed keystroke sequence |
967 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
880 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
1303 CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray(); |
1218 CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray(); |
1304 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
1219 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
1305 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
1220 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
1306 TBuf<KMaxKeystrokeCount> showInfo; |
1221 TBuf<KMaxKeystrokeCount> showInfo; |
1307 TBuf<KMaxKeystrokeCount> keyBuf; |
1222 TBuf<KMaxKeystrokeCount> keyBuf; |
1308 |
|
1309 // Get the current core id |
|
1310 TInt coreID = 0; |
|
1311 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
1312 TInt phraseCount = 0; |
|
1313 |
|
1314 for (TInt i = 0; i < phrase->Count(); ++i) |
1223 for (TInt i = 0; i < phrase->Count(); ++i) |
1315 { |
1224 { |
1316 // If this method is called in construction of the state machine, |
1225 showInfo.Append(phrase->MdcaPoint(i) ); |
1317 // the plugin is not set. If sogou core is in use now, we should append |
|
1318 // each characters to showInfo. |
|
1319 // For Sogou core, maybe one element of PhraseArray() contains two or more characters. |
|
1320 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1321 { |
|
1322 for ( TInt k = 0; k < phrase->MdcaPoint(i).Length(); k++ ) |
|
1323 { |
|
1324 showInfo.Append( phrase->MdcaPoint(i)[k] ); |
|
1325 } |
|
1326 phraseCount += phrase->MdcaPoint(i).Length(); |
|
1327 } |
|
1328 else |
|
1329 { |
|
1330 // If cpicore is in use, just append the element of phrase |
|
1331 showInfo.Append(phrase->MdcaPoint(i) ); |
|
1332 } |
|
1333 } |
1226 } |
1334 |
1227 |
1335 for (TInt ii = 0; ii < showKeystroke->Count(); ++ii) |
1228 for (TInt ii = 0; ii < showKeystroke->Count(); ++ii) |
1336 { |
1229 { |
1337 showInfo.Append(showKeystroke->MdcaPoint(ii) ); |
1230 showInfo.Append(showKeystroke->MdcaPoint(ii) ); |
1339 |
1232 |
1340 for (TInt j = 0; j < keystrokeArray->Count(); ++j) |
1233 for (TInt j = 0; j < keystrokeArray->Count(); ++j) |
1341 { |
1234 { |
1342 keyBuf.Append(keystrokeArray->MdcaPoint(j) ); |
1235 keyBuf.Append(keystrokeArray->MdcaPoint(j) ); |
1343 } |
1236 } |
1344 |
1237 |
1345 // If this method is called in construction of the state machine, |
1238 editPane->SetTextForZhuyin(showInfo, GetCursorPos(), phrase->Count(), |
1346 // the plugin is not set. If sogou core is in use now, the phraseCount |
|
1347 // should be the same as the phrase characters count. |
|
1348 // For Sogou core, maybe one element of PhraseArray() contains two or more characters. |
|
1349 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1350 { |
|
1351 editPane->SetTextForZhuyin(showInfo, GetCursorPos(), phraseCount, |
|
1352 keyBuf, editPane->GetCursorIndexOfKeystroke() ); |
|
1353 } |
|
1354 else |
|
1355 { |
|
1356 // If cpicore is in use, phraseCount is the same as phrase->Count() |
|
1357 editPane->SetTextForZhuyin(showInfo, GetCursorPos(), phrase->Count(), |
|
1358 keyBuf, editPane->GetCursorIndexOfKeystroke() ); |
1239 keyBuf, editPane->GetCursorIndexOfKeystroke() ); |
1359 } |
|
1360 |
1240 |
1361 if (iState == ECandidate) |
1241 if (iState == ECandidate) |
1362 { |
1242 { |
1363 editPane->DisableCursor(); |
1243 editPane->DisableCursor(); |
1364 } |
1244 } |
1424 uiContainer->ShowHorizontalScrollArrows(EFalse); |
1304 uiContainer->ShowHorizontalScrollArrows(EFalse); |
1425 uiContainer->ShowVerticalScrollArrows(EFalse); |
1305 uiContainer->ShowVerticalScrollArrows(EFalse); |
1426 uiContainer->SetControlInVisible( EFalse ); |
1306 uiContainer->SetControlInVisible( EFalse ); |
1427 } |
1307 } |
1428 } |
1308 } |
1429 |
|
1430 //------------------------------------------------------------------------------- |
1309 //------------------------------------------------------------------------------- |
1431 // Purpose: to adjust the scancode to make pinyin works |
1310 // Purpose: to adjust the scancode to make pinyin works |
1432 // Pinyin symbol inheritantly accepts A-Z, any input out of this range will make it crash. |
1311 // Pinyin symbol inheritantly accepts A-Z, any input out of this range will make it crash. |
1433 // Add this function to turn some alienated scancode to A-Z. |
1312 // Add this function to turn some alienated scancode to A-Z. |
1434 // |
1313 // |
1445 { |
1324 { |
1446 aKey = upperdata[0]; |
1325 aKey = upperdata[0]; |
1447 } |
1326 } |
1448 } |
1327 } |
1449 } |
1328 } |
|
1329 |
1450 // --------------------------------------------------------------------------- |
1330 // --------------------------------------------------------------------------- |
1451 // TAknFepInputMiniQwertyPinyinPhraseBase::GetShowKeystroke |
1331 // TAknFepInputMiniQwertyPinyinPhraseBase::GetShowKeystroke |
1452 //Handle horizontal navigation. |
1332 //Handle horizontal navigation. |
1453 // --------------------------------------------------------------------------- |
1333 // --------------------------------------------------------------------------- |
1454 // |
1334 // |
1654 // --------------------------------------------------------- |
1534 // --------------------------------------------------------- |
1655 // |
1535 // |
1656 void TAknFepInputMiniQwertyPinyinPhraseBase::AddPhraseToDB( |
1536 void TAknFepInputMiniQwertyPinyinPhraseBase::AddPhraseToDB( |
1657 const TDesC& aPhraseAdd) |
1537 const TDesC& aPhraseAdd) |
1658 { |
1538 { |
1659 if ( iPlugin.IsEnable()) |
|
1660 { |
|
1661 iPlugin.AddPhrasePinyinToPti(); |
|
1662 return; |
|
1663 } |
|
1664 TPtiUserDictionaryEntry addUdbEntry(aPhraseAdd); |
1539 TPtiUserDictionaryEntry addUdbEntry(aPhraseAdd); |
1665 //Add the phrase to the DB by PTI Engine |
1540 //Add the phrase to the DB by PTI Engine |
1666 iOwner->PtiEngine()->AddUserDictionaryEntry(addUdbEntry); |
1541 iOwner->PtiEngine()->AddUserDictionaryEntry(addUdbEntry); |
1667 } |
1542 } |
1668 |
1543 |
1711 // --------------------------------------------------------------------------- |
1586 // --------------------------------------------------------------------------- |
1712 // |
1587 // |
1713 TBool TAknFepInputMiniQwertyPinyinPhraseBase::CommitInlineEEPL( |
1588 TBool TAknFepInputMiniQwertyPinyinPhraseBase::CommitInlineEEPL( |
1714 const TDesC& aDes) |
1589 const TDesC& aDes) |
1715 { |
1590 { |
1716 // If sogou core is actived, use the plugin. |
|
1717 if ( iPlugin.IsEnable()) |
|
1718 { |
|
1719 return iPlugin.CommitInlineEEPL( aDes ); |
|
1720 } |
|
1721 |
|
1722 TInt charCount = aDes.Length(); |
1591 TInt charCount = aDes.Length(); |
1723 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
1592 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
1724 MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
1593 MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
1725 CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray(); |
1594 CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray(); |
1726 CDesCArrayFlat* keyStoke = editpane->KeystrokeArray(); |
1595 CDesCArrayFlat* keyStoke = editpane->KeystrokeArray(); |
1824 TInt phraseCount = editPane->PhraseArray()->Count(); |
1693 TInt phraseCount = editPane->PhraseArray()->Count(); |
1825 TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count(); |
1694 TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count(); |
1826 TInt index = editPane->GetCursorIndexOfKeystroke(); |
1695 TInt index = editPane->GetCursorIndexOfKeystroke(); |
1827 TBuf<1> keystroke; |
1696 TBuf<1> keystroke; |
1828 |
1697 |
1829 // Get the current core id |
|
1830 TInt coreID = 0; |
|
1831 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
1832 |
|
1833 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1834 { |
|
1835 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
1836 phraseCount = 0; |
|
1837 for ( TInt j = 0; j < phrase->Count(); j++ ) |
|
1838 { |
|
1839 phraseCount += phrase->MdcaPoint(j).Length();; |
|
1840 } |
|
1841 } |
|
1842 |
|
1843 if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount ) |
1698 if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount ) |
1844 { |
1699 { |
1845 return EFalse; |
1700 return EFalse; |
1846 } |
1701 } |
1847 |
1702 |
1848 GetShowKeystroke(aKey, keystroke); |
1703 GetShowKeystroke(aKey, keystroke); |
1849 |
|
1850 //Add this condition to avoid crash in case keystroke is empty. |
1704 //Add this condition to avoid crash in case keystroke is empty. |
1851 if(keystroke.Length() == 0) |
1705 if(keystroke.Length() == 0) |
1852 { |
1706 { |
1853 return EFalse; |
1707 return EFalse; |
1854 } |
1708 } |
1855 |
|
1856 if ( index >= keystrokeArray->Count() ) |
1709 if ( index >= keystrokeArray->Count() ) |
1857 { |
1710 { |
1858 keystrokeArray->AppendL(keystroke); |
1711 keystrokeArray->AppendL(keystroke); |
1859 editPane->SetCursorIndexOfKeystroke(keystrokeArray->Count() ); |
1712 editPane->SetCursorIndexOfKeystroke(keystrokeArray->Count() ); |
1860 } |
1713 } |
1983 // Get the candidate info. |
1836 // Get the candidate info. |
1984 // --------------------------------------------------------- |
1837 // --------------------------------------------------------- |
1985 // |
1838 // |
1986 void TAknFepInputMiniQwertyPinyinPhraseBase::GetCandidateL() |
1839 void TAknFepInputMiniQwertyPinyinPhraseBase::GetCandidateL() |
1987 { |
1840 { |
1988 if ( iPlugin.IsEnable()) |
|
1989 { |
|
1990 iPlugin.GetCandidateL(); |
|
1991 return; |
|
1992 } |
|
1993 |
|
1994 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
1841 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
1995 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
1842 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
1996 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
1843 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
1997 CDesCArrayFlat* phraseCandidates = |
1844 CDesCArrayFlat* phraseCandidates = |
1998 uiContainer->CandidatePane()->CandidateArray(); |
1845 uiContainer->CandidatePane()->CandidateArray(); |
2125 |
1972 |
2126 editPane->SetCursorIndexOfKeystroke(buf.Length() ); |
1973 editPane->SetCursorIndexOfKeystroke(buf.Length() ); |
2127 keystrokeArray->Compress(); |
1974 keystrokeArray->Compress(); |
2128 phrase->Compress(); |
1975 phrase->Compress(); |
2129 phraseStroke->Compress(); |
1976 phraseStroke->Compress(); |
2130 |
1977 |
2131 TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); |
|
2132 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
2133 { |
|
2134 // Notify sogoucore that last phrase is cancelled |
|
2135 iOwner->PtiEngine()->HandleCommandL( EPtiCommandCancelSelectElement ); |
|
2136 } |
|
2137 } |
1978 } |
2138 |
1979 |
2139 // --------------------------------------------------------- |
1980 // --------------------------------------------------------- |
2140 // TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor |
1981 // TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor |
2141 // Set warning color. |
1982 // Set warning color. |
2157 - 1) ) || (KInvalidToneMark |
1998 - 1) ) || (KInvalidToneMark |
2158 != ToneMark( aShowKeystroke->MdcaPoint( aI - 1 ) ) )) |
1999 != ToneMark( aShowKeystroke->MdcaPoint( aI - 1 ) ) )) |
2159 { |
2000 { |
2160 editPane->SetHighlight(aPhraseCount + aIndex, aPhraseCount |
2001 editPane->SetHighlight(aPhraseCount + aIndex, aPhraseCount |
2161 + aIndex + aCount - 1 ); |
2002 + aIndex + aCount - 1 ); |
2162 if ( iPlugin.IsEnable()) |
|
2163 { |
|
2164 iPlugin.CanConvertAll( EFalse ); |
|
2165 iPlugin.ConvertCount( aIndex ); |
|
2166 } |
|
2167 } |
2003 } |
2168 else |
2004 else |
2169 { |
2005 { |
2170 TPtrC ptr1 = getCurrentLeastDLTSpell(); |
2006 TPtrC ptr1 = getCurrentLeastDLTSpell(); |
2171 for (TInt j = 0; j < aToneMark; ++j) |
2007 for (TInt j = 0; j < aToneMark; ++j) |
2186 != ptr2.Mid( ptr2.Length() - 1, 1 ). |
2022 != ptr2.Mid( ptr2.Length() - 1, 1 ). |
2187 CompareC( aShowKeystroke->MdcaPoint( aI ) ) )) |
2023 CompareC( aShowKeystroke->MdcaPoint( aI ) ) )) |
2188 { |
2024 { |
2189 editPane->SetHighlight( aPhraseCount + aIndex, aPhraseCount |
2025 editPane->SetHighlight( aPhraseCount + aIndex, aPhraseCount |
2190 + aIndex + aCount - 1); |
2026 + aIndex + aCount - 1); |
2191 if ( iPlugin.IsEnable()) |
|
2192 { |
|
2193 iPlugin.CanConvertAll( EFalse ); |
|
2194 iPlugin.ConvertCount( aIndex ); |
|
2195 } |
|
2196 } |
2027 } |
2197 } |
2028 } |
2198 ClearPtiEngineKeystroke(); |
2029 ClearPtiEngineKeystroke(); |
2199 } |
2030 } |
2200 |
2031 |
2215 TInt stringBeforeLength = 0; |
2046 TInt stringBeforeLength = 0; |
2216 TInt stringAfterLength = 0; |
2047 TInt stringAfterLength = 0; |
2217 TInt start = 0; |
2048 TInt start = 0; |
2218 TInt keyCode = 0; |
2049 TInt keyCode = 0; |
2219 TInt toneMark = KInvalidToneMark; |
2050 TInt toneMark = KInvalidToneMark; |
2220 |
|
2221 if ( iPlugin.IsEnable()) |
|
2222 { |
|
2223 iPlugin.CanConvertAll( ETrue ); |
|
2224 } |
|
2225 // Get the current core id |
|
2226 TInt coreID = 0; |
|
2227 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
2228 |
|
2229 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
2230 { |
|
2231 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
2232 phraseCount = 0; |
|
2233 for ( TInt j = 0; j < phrase->Count(); j++ ) |
|
2234 { |
|
2235 phraseCount += phrase->MdcaPoint(j).Length();; |
|
2236 } |
|
2237 } |
|
2238 |
2051 |
2239 if (showKeystroke->Count() == 0) |
2052 if (showKeystroke->Count() == 0) |
2240 { |
2053 { |
2241 return; |
2054 return; |
2242 } |
2055 } |
2243 |
2056 |
2244 if ( TUid::Uid( coreID ) != KPtiSogouCoreUid ) |
2057 if (CheckAllGroupStroke() ) |
2245 { |
2058 { |
2246 if ( CheckAllGroupStroke()) |
2059 return; |
2247 { |
2060 } |
2248 return; |
|
2249 } |
|
2250 } |
|
2251 |
|
2252 ClearPtiEngineKeystroke(); |
2061 ClearPtiEngineKeystroke(); |
2253 if (CheckSpellingDLT(showKeystroke->MdcaPoint( 0) ) || (KInvalidToneMark |
2062 if (CheckSpellingDLT(showKeystroke->MdcaPoint( 0) ) || (KInvalidToneMark |
2254 != ToneMark(showKeystroke->MdcaPoint( 0) ) )) |
2063 != ToneMark(showKeystroke->MdcaPoint( 0) ) )) |
2255 { |
2064 { |
2256 start = 1; |
2065 start = 1; |
2257 editPane->SetHighlight(phraseCount, phraseCount); |
2066 editPane->SetHighlight(phraseCount, phraseCount); |
2258 |
|
2259 if ( iPlugin.IsEnable()) |
|
2260 { |
|
2261 iPlugin.CanConvertAll( EFalse ); |
|
2262 iPlugin.ConvertCount( index ); |
|
2263 } |
|
2264 |
|
2265 index = 1; |
2067 index = 1; |
2266 } |
2068 } |
2267 |
2069 |
2268 TInt end = showKeystroke->Count(); |
2070 for ( TInt i = start; i < showKeystroke->Count(); ++i ) |
2269 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
2270 { |
|
2271 for ( TInt j = showKeystroke->Count() - 1; j >= 0; j-- ) |
|
2272 { |
|
2273 if ( KAutoDLT == showKeystroke->MdcaPoint(j)[0] ) |
|
2274 { |
|
2275 end = j + 1; |
|
2276 break; |
|
2277 } |
|
2278 } |
|
2279 } |
|
2280 |
|
2281 for ( TInt i = start; i < end; ++i ) |
|
2282 { |
2071 { |
2283 count = count + 1; |
2072 count = count + 1; |
2284 // tone mark |
2073 // tone mark |
2285 toneMark = ToneMark(showKeystroke->MdcaPoint(i) ); |
2074 toneMark = ToneMark(showKeystroke->MdcaPoint(i) ); |
2286 if ( KInvalidToneMark != toneMark ) |
2075 if ( KInvalidToneMark != toneMark ) |
2304 || (KInvalidToneMark |
2093 || (KInvalidToneMark |
2305 != ToneMark(showKeystroke->MdcaPoint(i - 1) ) )) |
2094 != ToneMark(showKeystroke->MdcaPoint(i - 1) ) )) |
2306 { |
2095 { |
2307 editPane->SetHighlight(phraseCount + index, phraseCount |
2096 editPane->SetHighlight(phraseCount + index, phraseCount |
2308 + index + count - 1); |
2097 + index + count - 1); |
2309 if ( iPlugin.IsEnable()) |
|
2310 { |
|
2311 iPlugin.CanConvertAll( EFalse ); |
|
2312 iPlugin.ConvertCount( index ); |
|
2313 } |
|
2314 } |
2098 } |
2315 ClearPtiEngineKeystroke(); |
2099 ClearPtiEngineKeystroke(); |
2316 index = i + 1; |
2100 index = i + 1; |
2317 count = 0; |
2101 count = 0; |
2318 valid = ETrue; |
2102 valid = ETrue; |
2320 else |
2104 else |
2321 { |
2105 { |
2322 if ( valid ) |
2106 if ( valid ) |
2323 { |
2107 { |
2324 GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) ); |
2108 GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) ); |
2325 |
2109 stringBeforeLength = getCurrentLeastDLTSpell().Length(); |
2326 // dltBeforeCount is the dlt count before append the key. |
2110 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
2327 // dltAfterCount is the dlt count after append the key. |
2111 stringAfterLength = getCurrentLeastDLTSpell().Length(); |
2328 // In sogou core, after appending a new key, the spell length |
2112 if ( stringBeforeLength == stringAfterLength )//the keystroke is invalid |
2329 // may be the same, but the dlt count will change. |
|
2330 // In this situation, the appended key is valid. |
|
2331 TInt dltBeforeCount = 0; |
|
2332 TInt dltAfterCount = 0; |
|
2333 TPtrC stringBefore = getCurrentLeastDLTSpell(); |
|
2334 stringBeforeLength = stringBefore.Length(); |
|
2335 for ( TInt j = 0; j < stringBefore.Length(); j++ ) |
|
2336 { |
|
2337 if ( CheckSpellingDLT( stringBefore.Mid( j ))) |
|
2338 { |
|
2339 dltBeforeCount++; |
|
2340 } |
|
2341 } |
|
2342 |
|
2343 // Append the key. |
|
2344 ptiengine->AppendKeyPress(( TPtiKey )keyCode ).Length(); |
|
2345 |
|
2346 // Get the dlt count after appending the key. |
|
2347 TPtrC stringAfter = getCurrentLeastDLTSpell(); |
|
2348 stringAfterLength = stringAfter.Length(); |
|
2349 for ( TInt k = 0; k < stringAfter.Length(); k++ ) |
|
2350 { |
|
2351 if ( CheckSpellingDLT( stringAfter.Mid( k ))) |
|
2352 { |
|
2353 dltAfterCount++; |
|
2354 } |
|
2355 } |
|
2356 |
|
2357 // If the spell length is the same and the dlt count is |
|
2358 // the same, the keystroke is invalid |
|
2359 if (( stringBeforeLength == stringAfterLength ) && |
|
2360 ( dltAfterCount == dltBeforeCount )) |
|
2361 { |
2113 { |
2362 ClearPtiEngineKeystroke(); |
2114 ClearPtiEngineKeystroke(); |
2363 valid = EFalse; |
2115 valid = EFalse; |
2364 } |
2116 } |
2365 } |
2117 } |
2368 if ( ( showKeystroke->Count() == i + 1 ) && ( !valid ) ) |
2120 if ( ( showKeystroke->Count() == i + 1 ) && ( !valid ) ) |
2369 { |
2121 { |
2370 editPane->SetHighlight( |
2122 editPane->SetHighlight( |
2371 phraseCount + index, |
2123 phraseCount + index, |
2372 phraseCount + index + count - 1 ); |
2124 phraseCount + index + count - 1 ); |
2373 |
|
2374 if ( iPlugin.IsEnable()) |
|
2375 { |
|
2376 iPlugin.CanConvertAll( EFalse ); |
|
2377 iPlugin.ConvertCount( index ); |
|
2378 } |
|
2379 |
|
2380 ClearPtiEngineKeystroke(); |
2125 ClearPtiEngineKeystroke(); |
2381 } |
2126 } |
2382 } |
2127 } |
2383 } |
2128 } |
2384 |
2129 |
2430 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
2175 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
2431 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
2176 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
2432 CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray(); |
2177 CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray(); |
2433 TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count(); |
2178 TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count(); |
2434 TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke(); |
2179 TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke(); |
2435 |
2180 TInt cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count(); |
2436 TInt cursorPos = 0; |
2181 |
2437 // Get the current core id |
|
2438 TInt coreID = 0; |
|
2439 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
2440 TInt phraseCount = 0; |
|
2441 |
|
2442 // For Sogou core, maybe on element of PhraseArray() contains two or |
|
2443 // more characters. |
|
2444 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
2445 { |
|
2446 for ( TInt l = 0; l < editPane->PhraseArray()->Count(); l++ ) |
|
2447 { |
|
2448 phraseCount += editPane->PhraseArray()->MdcaPoint( l ).Length(); |
|
2449 } |
|
2450 cursorPos = editPane->GetCursor() - phraseCount; |
|
2451 } |
|
2452 else |
|
2453 { |
|
2454 cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count(); |
|
2455 } |
|
2456 |
|
2457 TBuf<1> autoDLT; |
2182 TBuf<1> autoDLT; |
2458 autoDLT.Append(KAutoDLT); |
2183 autoDLT.Append(KAutoDLT); |
2459 const TInt offset = 2; |
2184 const TInt offset = 2; |
2460 if (cursorPos <= 0) |
2185 if (cursorPos <= 0) |
2461 { |
2186 { |
2505 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
2230 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
2506 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
2231 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
2507 CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray(); |
2232 CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray(); |
2508 TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count(); |
2233 TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count(); |
2509 TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke(); |
2234 TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke(); |
2510 |
2235 TInt cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count(); |
2511 TInt cursorPos = 0; |
|
2512 // Get the current core id |
|
2513 TInt coreID = 0; |
|
2514 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
2515 TInt phraseCount = 0; |
|
2516 |
|
2517 // For Sogou core, maybe on element of PhraseArray() contains two or |
|
2518 // more characters. |
|
2519 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
2520 { |
|
2521 for ( TInt l = 0; l < editPane->PhraseArray()->Count(); l++ ) |
|
2522 { |
|
2523 phraseCount += editPane->PhraseArray()->MdcaPoint( l ).Length(); |
|
2524 } |
|
2525 cursorPos = editPane->GetCursor() - phraseCount; |
|
2526 } |
|
2527 else |
|
2528 { |
|
2529 cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count(); |
|
2530 } |
|
2531 |
|
2532 TBuf<1> autoDLT; |
2236 TBuf<1> autoDLT; |
2533 autoDLT.Append(KAutoDLT); |
2237 autoDLT.Append(KAutoDLT); |
2534 const TInt offset = 2; |
2238 const TInt offset = 2; |
2535 |
2239 |
2536 if (cursorPos <= 0) |
2240 if (cursorPos <= 0) |
2777 // --------------------------------------------------------- |
2481 // --------------------------------------------------------- |
2778 // |
2482 // |
2779 void TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyFromCandidateL( |
2483 void TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyFromCandidateL( |
2780 TInt aKey, TKeyPressLength /*aLength*/) |
2484 TInt aKey, TKeyPressLength /*aLength*/) |
2781 { |
2485 { |
|
2486 TInt index = 0; |
2782 #ifdef RD_INTELLIGENT_TEXT_INPUT |
2487 #ifdef RD_INTELLIGENT_TEXT_INPUT |
2783 // it may be one of the 'valid' numbers.. |
2488 // it may be one of the 'valid' numbers.. |
2784 TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout(); |
2489 TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout(); |
2785 if (EPtiKeyboardQwerty4x10 == keyboardtype || EPtiKeyboardQwerty3x11 |
2490 if (EPtiKeyboardQwerty4x10 == keyboardtype || EPtiKeyboardQwerty3x11 |
2786 == keyboardtype || EPtiKeyboardHalfQwerty == keyboardtype |
2491 == keyboardtype || EPtiKeyboardHalfQwerty == keyboardtype |
2804 TPtiNumericKeyBinding numKeyBind = |
2509 TPtiNumericKeyBinding numKeyBind = |
2805 keybinding[numericKeysCount]; |
2510 keybinding[numericKeysCount]; |
2806 if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36) |
2511 if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36) |
2807 &&(aKey == numKeyBind.iKey)) |
2512 &&(aKey == numKeyBind.iKey)) |
2808 { |
2513 { |
|
2514 index = numKeyBind.iChar - EPtiKey0 -1; |
2809 validnumkey = ETrue; |
2515 validnumkey = ETrue; |
2810 break; |
2516 break; |
2811 } |
2517 } |
2812 } |
2518 } |
2813 } |
2519 } |
2817 { |
2523 { |
2818 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
2524 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
2819 return; |
2525 return; |
2820 } |
2526 } |
2821 } |
2527 } |
|
2528 else |
|
2529 { |
|
2530 #endif |
|
2531 index = MapKeyToIndex(aKey); |
|
2532 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
2533 } |
2822 #endif |
2534 #endif |
2823 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
2535 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
2824 |
2536 |
2825 if ( aKey == EStdKeyDevice3 || aKey |
2537 if (candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey |
2826 == EStdKeyEnter) |
2538 == EStdKeyEnter) |
2827 { |
2539 { |
2828 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
2540 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
2829 if (text.Length() ) |
2541 if (text.Length() ) |
2830 { |
2542 { |
2917 && (KInvalidToneMark != ToneMark(keystroke->MdcaPoint( i - 1 ) ) ) ) |
2629 && (KInvalidToneMark != ToneMark(keystroke->MdcaPoint( i - 1 ) ) ) ) |
2918 { |
2630 { |
2919 return EFalse; |
2631 return EFalse; |
2920 } |
2632 } |
2921 GetKeystrokeCode(keyCode, keystroke->MdcaPoint(i) ); |
2633 GetKeystrokeCode(keyCode, keystroke->MdcaPoint(i) ); |
2922 |
2634 stringBeforeLength = getCurrentLeastDLTSpell().Length(); |
2923 // dltBeforeCount is the dlt count before append the key. |
2635 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
2924 // dltAfterCount is the dlt count after append the key. |
2636 stringAfterLength = getCurrentLeastDLTSpell().Length(); |
2925 // In sogou core, after appending a new key, the spell length |
2637 if ( stringBeforeLength == stringAfterLength ) |
2926 // may be the same, but the dlt count will change. |
|
2927 // In this situation, the appended key is valid. |
|
2928 TInt dltBeforeCount = 0; |
|
2929 TInt dltAfterCount = 0; |
|
2930 TPtrC stringBefore = getCurrentLeastDLTSpell(); |
|
2931 stringBeforeLength = stringBefore.Length(); |
|
2932 for ( TInt k = 0; k < stringBefore.Length(); k++ ) |
|
2933 { |
|
2934 if ( CheckSpellingDLT( stringBefore.Mid( k ))) |
|
2935 { |
|
2936 dltBeforeCount++; |
|
2937 } |
|
2938 } |
|
2939 |
|
2940 // Append the key. |
|
2941 ptiengine->AppendKeyPress(( TPtiKey )keyCode ); |
|
2942 |
|
2943 // Get the dlt count after appending the key. |
|
2944 TPtrC stringAfter = getCurrentLeastDLTSpell(); |
|
2945 stringAfterLength = stringAfter.Length(); |
|
2946 for ( TInt l = 0; l < stringAfter.Length(); l++ ) |
|
2947 { |
|
2948 if ( CheckSpellingDLT( stringAfter.Mid( l ))) |
|
2949 { |
|
2950 dltAfterCount++; |
|
2951 } |
|
2952 } |
|
2953 |
|
2954 // If the spell length is the same and the dlt count is |
|
2955 // the same, the keystroke is invalid |
|
2956 if (( stringBeforeLength == stringAfterLength ) && |
|
2957 ( dltAfterCount == dltBeforeCount )) |
|
2958 { |
2638 { |
2959 return EFalse; |
2639 return EFalse; |
2960 } |
2640 } |
2961 } |
2641 } |
2962 } |
2642 } |
3007 errnote->SetTone(CAknNoteDialog::EWarningTone); |
2687 errnote->SetTone(CAknNoteDialog::EWarningTone); |
3008 errnote->ExecuteLD(KMaxPhraseNote); |
2688 errnote->ExecuteLD(KMaxPhraseNote); |
3009 } |
2689 } |
3010 else |
2690 else |
3011 { |
2691 { |
3012 // For sogou core, the predictive is not endless, so when there |
|
3013 // is no predictive candidates, we should call TryCloseUiL(). |
|
3014 TBool noCandidates = EFalse; |
|
3015 |
|
3016 TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); |
|
3017 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
3018 { |
|
3019 // Get the predictive candidates. |
|
3020 CDesCArrayFlat* phraseCandidates = new(ELeave) CDesCArrayFlat( 1 ); |
|
3021 CleanupStack::PushL ( phraseCandidates ); |
|
3022 phraseCandidates->Reset(); |
|
3023 iOwner->PtiEngine()->GetChinesePhraseCandidatesL( *phraseCandidates ); |
|
3024 if ( phraseCandidates->Count() == 0 ) |
|
3025 { |
|
3026 noCandidates = ETrue; |
|
3027 } |
|
3028 CleanupStack::PopAndDestroy( phraseCandidates ); |
|
3029 } |
|
3030 |
|
3031 UIContainer()->EditPaneWindow()->ResetAllArray(); |
2692 UIContainer()->EditPaneWindow()->ResetAllArray(); |
3032 if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag() && !noCandidates ) |
2693 if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag() ) |
3033 { |
2694 { |
3034 UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse); |
2695 UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse); |
3035 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
2696 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
3036 iOwner->ChangeState(EPredictiveCandidate); |
2697 iOwner->ChangeState(EPredictiveCandidate); |
3037 } |
2698 } |