53 const TInt16 KStrokeDelimiter = 0x2022; |
53 const TInt16 KStrokeDelimiter = 0x2022; |
54 const TInt16 KStrokeUnicode = 0x2461; |
54 const TInt16 KStrokeUnicode = 0x2461; |
55 const TInt16 KKey1 = 0x31; |
55 const TInt16 KKey1 = 0x31; |
56 const TInt16 KKey6 = 0x36; |
56 const TInt16 KKey6 = 0x36; |
57 |
57 |
|
58 const TUid KPtiSogouCoreUid = { 0x20031DD6 }; |
|
59 |
58 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" ); |
60 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" ); |
59 |
61 |
60 // --------------------------------------------------------------------------- |
62 // --------------------------------------------------------------------------- |
61 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
63 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
62 // C++ default constructor |
64 // C++ default constructor |
227 keyCode = (*keycodeArray)[i]; |
229 keyCode = (*keycodeArray)[i]; |
228 stringBeforeLength = |
230 stringBeforeLength = |
229 ptiengine->GetPhoneticSpelling(1).Length(); |
231 ptiengine->GetPhoneticSpelling(1).Length(); |
230 stringAfterLength = |
232 stringAfterLength = |
231 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
233 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
234 stringAfterLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
235 |
232 //the keystroke is invalid. |
236 //the keystroke is invalid. |
233 if ( stringBeforeLength == stringAfterLength ) |
237 if ( stringBeforeLength == stringAfterLength ) |
234 { |
238 { |
235 return EFalse; |
239 return EFalse; |
236 } |
240 } |
465 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
469 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
466 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
470 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
467 TInt index = editPane->GetCursorIndexOfKeystroke(); |
471 TInt index = editPane->GetCursorIndexOfKeystroke(); |
468 TBuf<KMaxKeystrokeCount> showInfo; |
472 TBuf<KMaxKeystrokeCount> showInfo; |
469 |
473 |
|
474 // Get the current core id |
|
475 TInt coreID = 0; |
|
476 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
477 TInt phraseCount = 0; |
|
478 |
470 for ( TInt i = 0; i < phrase->Count(); ++i ) |
479 for ( TInt i = 0; i < phrase->Count(); ++i ) |
471 { |
480 { |
472 showInfo.Append( phrase->MdcaPoint( i ) ); |
481 // If this method is called in construction of the state machine, |
|
482 // the plugin is not set. If sogou core is in use now, we should append |
|
483 // each characters to showInfo. |
|
484 // For Sogou core, maybe one element of PhraseArray() contains two or more characters. |
|
485 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
486 { |
|
487 for ( TInt k = 0; k < phrase->MdcaPoint(i).Length(); k++ ) |
|
488 { |
|
489 showInfo.Append( phrase->MdcaPoint(i)[k] ); |
|
490 } |
|
491 phraseCount += phrase->MdcaPoint(i).Length(); |
|
492 } |
|
493 else |
|
494 { |
|
495 // If cpicore is in use, just append the element of phrase |
|
496 showInfo.Append(phrase->MdcaPoint(i) ); |
|
497 } |
473 } |
498 } |
474 |
499 |
475 for ( TInt ii = 0; ii < keystroke->Count(); ++ii ) |
500 for ( TInt ii = 0; ii < keystroke->Count(); ++ii ) |
476 { |
501 { |
477 showInfo.Append( keystroke->MdcaPoint( ii ) ); |
502 showInfo.Append( keystroke->MdcaPoint( ii ) ); |
478 } |
503 } |
479 |
504 |
480 editPane->SetText( showInfo, index + phrase->Count() ); |
505 // If this method is called in construction of the state machine, |
|
506 // the plugin is not set. If sogou core is in use now, the phraseCount |
|
507 // should be the same as the phrase characters count. |
|
508 // For Sogou core, maybe one element of PhraseArray() contains two or more characters. |
|
509 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
510 { |
|
511 editPane->SetText( showInfo, index + phraseCount ); |
|
512 } |
|
513 else |
|
514 { |
|
515 // If cpicore is in use, phraseCount is the same as phrase->Count() |
|
516 editPane->SetText( showInfo, index + phrase->Count() ); |
|
517 } |
481 |
518 |
482 switch ( iState ) |
519 switch ( iState ) |
483 { |
520 { |
484 case ECandidate: |
521 case ECandidate: |
485 editPane->DisableCursor(); |
522 editPane->DisableCursor(); |
700 // --------------------------------------------------------- |
737 // --------------------------------------------------------- |
701 // |
738 // |
702 void TAknFepInputMiniQwertyStrokePhraseBase::AddPhraseToDB( |
739 void TAknFepInputMiniQwertyStrokePhraseBase::AddPhraseToDB( |
703 const TDesC& aPhraseAdd ) |
740 const TDesC& aPhraseAdd ) |
704 { |
741 { |
|
742 // If sogou core is actived, use the plugin. |
|
743 if ( iStrokePlugin.IsEnable()) |
|
744 { |
|
745 iStrokePlugin.AddPhrasePinyinToPti(); |
|
746 return; |
|
747 } |
705 TPtiUserDictionaryEntry addUdbEntry( aPhraseAdd ); |
748 TPtiUserDictionaryEntry addUdbEntry( aPhraseAdd ); |
706 //Add the phrase to the DB by PTI Engine |
749 //Add the phrase to the DB by PTI Engine |
707 iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); |
750 iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); |
708 } |
751 } |
709 |
752 |
750 // Commint text to EEP or editor |
793 // Commint text to EEP or editor |
751 // --------------------------------------------------------------------------- |
794 // --------------------------------------------------------------------------- |
752 // |
795 // |
753 TBool TAknFepInputMiniQwertyStrokePhraseBase::CommitInlineEEPL( const TDesC& aDes ) |
796 TBool TAknFepInputMiniQwertyStrokePhraseBase::CommitInlineEEPL( const TDesC& aDes ) |
754 { |
797 { |
|
798 // If sogou core is actived, use the plugin. |
|
799 if ( iStrokePlugin.IsEnable()) |
|
800 { |
|
801 return iStrokePlugin.CommitInlineEEPL( aDes ); |
|
802 } |
755 TInt charCount = aDes.Length(); |
803 TInt charCount = aDes.Length(); |
756 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
804 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
757 MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
805 MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
758 CDesCArrayFlat* keyStoke = editpane->KeystrokeArray(); |
806 CDesCArrayFlat* keyStoke = editpane->KeystrokeArray(); |
759 RArray<TInt>* keycode = editpane->KeycodeArray(); |
807 RArray<TInt>* keycode = editpane->KeycodeArray(); |
844 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
892 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
845 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
893 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
846 TInt phraseCount = editPane->PhraseArray()->Count(); |
894 TInt phraseCount = editPane->PhraseArray()->Count(); |
847 TInt keystrokeCount = keystrokeArray->Count(); |
895 TInt keystrokeCount = keystrokeArray->Count(); |
848 TInt index = editPane->GetCursorIndexOfKeystroke(); |
896 TInt index = editPane->GetCursorIndexOfKeystroke(); |
849 |
897 |
|
898 // Get the current core id |
|
899 TInt coreID = 0; |
|
900 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
901 |
|
902 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
903 { |
|
904 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
905 phraseCount = 0; |
|
906 for ( TInt j = 0; j < phrase->Count(); j++ ) |
|
907 { |
|
908 phraseCount += phrase->MdcaPoint(j).Length();; |
|
909 } |
|
910 } |
|
911 |
850 if ( phraseCount + keystrokeCount >= KMaxKeystrokeCount ) |
912 if ( phraseCount + keystrokeCount >= KMaxKeystrokeCount ) |
851 { |
913 { |
852 return EFalse; |
914 return EFalse; |
853 } |
915 } |
854 |
916 |
915 TInt aKey, |
977 TInt aKey, |
916 TDes& aKeystroke |
978 TDes& aKeystroke |
917 ) |
979 ) |
918 { |
980 { |
919 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
981 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
920 TBuf<KMaxName> lowerdata; |
982 TBuf<KMaxName> lowerdata; |
|
983 |
|
984 // If the key is EPtiKeyQwertySpace, just append a KStrokeDelimiter. |
|
985 if ( aKey == EPtiKeyQwertySpace ) |
|
986 { |
|
987 TBuf<1> strokeDLT; |
|
988 strokeDLT.Append( KStrokeDelimiter ); |
|
989 aKeystroke.Copy( strokeDLT ); |
|
990 return; |
|
991 } |
|
992 |
921 ptiEngine->MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); |
993 ptiEngine->MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); |
922 TInt StrokeUnicodePosition =0; |
994 TInt StrokeUnicodePosition =0; |
923 |
995 |
924 if(lowerdata.Length()>0) |
996 if(lowerdata.Length()>0) |
925 { |
997 { |
988 |
1060 |
989 editPane->SetCursorIndexOfKeystroke( buf.Length() ); |
1061 editPane->SetCursorIndexOfKeystroke( buf.Length() ); |
990 keystrokeArray->Compress(); |
1062 keystrokeArray->Compress(); |
991 phrase->Compress(); |
1063 phrase->Compress(); |
992 phraseStroke->Compress(); |
1064 phraseStroke->Compress(); |
|
1065 |
|
1066 TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); |
|
1067 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1068 { |
|
1069 // Notify sogoucore that last phrase is cancelled |
|
1070 iOwner->PtiEngine()->HandleCommandL( EPtiCommandCancelSelectElement ); |
|
1071 } |
993 } |
1072 } |
994 |
1073 |
995 // --------------------------------------------------------- |
1074 // --------------------------------------------------------- |
996 // TAknFepInputMiniQwertyStrokePhraseBase::SetWarningColor |
1075 // TAknFepInputMiniQwertyStrokePhraseBase::SetWarningColor |
997 // Set warning color. |
1076 // Set warning color. |
1013 TInt keyCode = 0; |
1092 TInt keyCode = 0; |
1014 TInt invalidPos = 0; |
1093 TInt invalidPos = 0; |
1015 TBuf<1> delimiter; |
1094 TBuf<1> delimiter; |
1016 delimiter.Append( KStrokeDelimiter ); |
1095 delimiter.Append( KStrokeDelimiter ); |
1017 |
1096 |
|
1097 // Get the current core id |
|
1098 TInt coreID = 0; |
|
1099 TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); |
|
1100 |
|
1101 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1102 { |
|
1103 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
1104 phraseCount = 0; |
|
1105 for ( TInt j = 0; j < phrase->Count(); j++ ) |
|
1106 { |
|
1107 phraseCount += phrase->MdcaPoint(j).Length();; |
|
1108 } |
|
1109 } |
|
1110 |
1018 //set warning color stroke after 7th group when it's more than 7 groups. |
1111 //set warning color stroke after 7th group when it's more than 7 groups. |
1019 if ( 0 == keystrokeCount ) |
1112 if ( 0 == keystrokeCount ) |
1020 { |
1113 { |
1021 return; |
1114 return; |
1022 } |
1115 } |
1036 //GetKeystrokeCode( keyCode, keystrokeArray->MdcaPoint( i ) ); |
1129 //GetKeystrokeCode( keyCode, keystrokeArray->MdcaPoint( i ) ); |
1037 keyCode = (*keycodeArray)[i]; |
1130 keyCode = (*keycodeArray)[i]; |
1038 if ( EPtiKeyQwertySpace == keyCode ) |
1131 if ( EPtiKeyQwertySpace == keyCode ) |
1039 { |
1132 { |
1040 delimiterCount = delimiterCount + 1; |
1133 delimiterCount = delimiterCount + 1; |
1041 if ( delimiterCount == KMaxPhraseCreationCount ) |
1134 |
1042 { |
1135 // For Sogou core, there is no need to limit characters count to |
1043 if ( !valid ) |
1136 // KMaxPhraseCreationCount. |
|
1137 if ( TUid::Uid( coreID ) != KPtiSogouCoreUid ) |
|
1138 { |
|
1139 if ( delimiterCount == KMaxPhraseCreationCount ) |
1044 { |
1140 { |
1045 editPane->SetHighlight( |
1141 if ( !valid ) |
1046 phraseCount + index, |
1142 { |
1047 phraseCount + keystrokeCount - 1 ); |
1143 editPane->SetHighlight( |
|
1144 phraseCount + index, |
|
1145 phraseCount + keystrokeCount - 1 ); |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 editPane->SetHighlight( |
|
1150 phraseCount + i, |
|
1151 phraseCount + keystrokeCount - 1 ); |
|
1152 } |
|
1153 break; |
1048 } |
1154 } |
1049 else |
1155 } |
1050 { |
1156 |
1051 editPane->SetHighlight( |
|
1052 phraseCount + i, |
|
1053 phraseCount + keystrokeCount - 1 ); |
|
1054 } |
|
1055 break; |
|
1056 } |
|
1057 if ( ( !valid ) || ( 0 == i ) ) |
1157 if ( ( !valid ) || ( 0 == i ) ) |
1058 { |
1158 { |
1059 editPane->SetHighlight( |
1159 editPane->SetHighlight( |
1060 phraseCount + index, |
1160 phraseCount + index, |
1061 phraseCount + index + count - 1 ); |
1161 phraseCount + index + count - 1 ); |
1358 } |
1460 } |
1359 } |
1461 } |
1360 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
1462 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
1361 stringAfterLength = |
1463 stringAfterLength = |
1362 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
1464 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
1465 stringAfterLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
1466 |
1363 if ( stringBeforeLength == stringAfterLength ) |
1467 if ( stringBeforeLength == stringAfterLength ) |
1364 { |
1468 { |
1365 editPane->SetAllValidFlag( EFalse ); |
1469 editPane->SetAllValidFlag( EFalse ); |
1366 if ( 0 == lastDLTPos ) |
1470 if ( 0 == lastDLTPos ) |
1367 { |
1471 { |
1410 } |
1514 } |
1411 else if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag( ) ) |
1515 else if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag( ) ) |
1412 { |
1516 { |
1413 #ifdef RD_INTELLIGENT_TEXT_INPUT |
1517 #ifdef RD_INTELLIGENT_TEXT_INPUT |
1414 TBool isEditorFull = iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagEditorFull); |
1518 TBool isEditorFull = iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagEditorFull); |
1415 if ( !isEditorFull ) |
1519 |
|
1520 // For sogou core, the predictive is not endless, so when there |
|
1521 // is no predictive candidates, we should call TryCloseUiL(). |
|
1522 TBool noCandidates = EFalse; |
|
1523 |
|
1524 TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); |
|
1525 if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) |
|
1526 { |
|
1527 // Get the predictive candidates. |
|
1528 CDesCArrayFlat* phraseCandidates = new(ELeave) CDesCArrayFlat( 1 ); |
|
1529 CleanupStack::PushL ( phraseCandidates ); |
|
1530 phraseCandidates->Reset(); |
|
1531 iOwner->PtiEngine()->GetChinesePhraseCandidatesL( *phraseCandidates ); |
|
1532 if ( phraseCandidates->Count() == 0 ) |
|
1533 { |
|
1534 noCandidates = ETrue; |
|
1535 } |
|
1536 CleanupStack::PopAndDestroy( phraseCandidates ); |
|
1537 } |
|
1538 if ( !isEditorFull && !noCandidates ) |
1416 { |
1539 { |
1417 iOwner->ChangeState( EPredictiveCandidate ); |
1540 iOwner->ChangeState( EPredictiveCandidate ); |
1418 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
1541 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
1419 } |
1542 } |
1420 else |
1543 else |