106 TCallBack(HandleFindRepositoryCallBack, this), |
106 TCallBack(HandleFindRepositoryCallBack, this), |
107 iRepositoryFind); |
107 iRepositoryFind); |
108 |
108 |
109 iWatcherAdaptive = CFindRepositoryWatcher::NewL(KCRUidAvkon, |
109 iWatcherAdaptive = CFindRepositoryWatcher::NewL(KCRUidAvkon, |
110 TCallBack(HandleFindRepositoryCallBack, this), |
110 TCallBack(HandleFindRepositoryCallBack, this), |
111 iRepositoryFindAdaptive); |
111 iRepositoryFindAdaptive); |
112 iEikEnv = CEikonEnv::Static(); |
|
113 if (iEikEnv) |
|
114 { |
|
115 TUid appUid(iEikEnv->EikAppUi()->Application()->AppDllUid()); |
|
116 iIsPhoneBook = (appUid== KUidPhoneBook || appUid == KUidPhoneBookServer); |
|
117 } |
|
118 } |
112 } |
119 |
113 |
120 // --------------------------------------------------------- |
114 // --------------------------------------------------------- |
121 // CFindUtilChinese utils class |
115 // CFindUtilChinese utils class |
122 // --------------------------------------------------------- |
116 // --------------------------------------------------------- |
126 iSupportPRCChinese(EFalse), |
120 iSupportPRCChinese(EFalse), |
127 iCurInputMode(KSysInputMode), |
121 iCurInputMode(KSysInputMode), |
128 iSearchMethodPRC(EAdptSearchPinyin), |
122 iSearchMethodPRC(EAdptSearchPinyin), |
129 iSearchMethodTaiWan(EAdptSearchZhuyin), |
123 iSearchMethodTaiWan(EAdptSearchZhuyin), |
130 iSearchMethodHongKong(EAdptSearchStroke), |
124 iSearchMethodHongKong(EAdptSearchStroke), |
131 iSearchMethodAdaptive(EFalse), |
125 iSearchMethodAdaptive(EFalse) |
132 iEikEnv(NULL), |
|
133 iIsPhoneBook(EFalse) |
|
134 { |
126 { |
135 } |
127 } |
136 |
128 |
137 // --------------------------------------------------------- |
129 // --------------------------------------------------------- |
138 // Destructor |
130 // Destructor |
185 // --------------------------------------------------------- |
177 // --------------------------------------------------------- |
186 // |
178 // |
187 TBool CFindUtilChinese::DoTranslationL(TInt16 aHZUnicode, |
179 TBool CFindUtilChinese::DoTranslationL(TInt16 aHZUnicode, |
188 RPointerArray<HBufC>& aSpellList) |
180 RPointerArray<HBufC>& aSpellList) |
189 { |
181 { |
190 if(iEikEnv) |
182 if(CEikonEnv::Static()) |
191 { |
183 { |
192 if (iSearchMethodAdaptive && iIsPhoneBook) |
184 if (iSearchMethodAdaptive &&(CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidPhoneBook || |
|
185 CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidPhoneBookServer )) |
193 { |
186 { |
194 if (!T9ChineseTranslationAdaptiveL(aHZUnicode, aSpellList)) |
187 if (!T9ChineseTranslationAdaptiveL(aHZUnicode, aSpellList)) |
195 { |
188 { |
196 return EFalse; |
189 return EFalse; |
197 } |
190 } |
323 |
316 |
324 for (TInt i =0; i < len; i++) |
317 for (TInt i =0; i < len; i++) |
325 { |
318 { |
326 if (wordInterpretationBuf[i] == KSeperator) |
319 if (wordInterpretationBuf[i] == KSeperator) |
327 { |
320 { |
328 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); |
321 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
329 aSpellList.AppendL(tmpStr); |
|
330 CleanupStack::Pop(tmpStr); |
|
331 start = i + 1; |
322 start = i + 1; |
332 } |
323 } |
333 } |
324 } |
334 |
325 |
335 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); |
326 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
336 aSpellList.AppendL(tmpStr); |
327 |
337 CleanupStack::Pop(tmpStr); |
328 |
338 |
|
339 return ETrue; |
329 return ETrue; |
340 } |
330 } |
341 |
331 |
342 // --------------------------------------------------------- |
332 // --------------------------------------------------------- |
343 // Do translate for Chinese word |
333 // Do translate for Chinese word |
466 { |
456 { |
467 for (TInt i =0; i < len; i++) |
457 for (TInt i =0; i < len; i++) |
468 { |
458 { |
469 if (wordInterpretationBuf[i] == KSeperator) |
459 if (wordInterpretationBuf[i] == KSeperator) |
470 { |
460 { |
471 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); |
461 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
472 aSpellList.AppendL(tmpStr); |
|
473 CleanupStack::Pop(tmpStr); |
|
474 start = i + 1; |
462 start = i + 1; |
475 } |
463 } |
476 } |
464 } |
477 |
465 |
478 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); |
466 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
479 aSpellList.AppendL(tmpStr); |
|
480 CleanupStack::Pop(tmpStr); |
|
481 } |
467 } |
482 //Could look advanced cangjie as normal and easy cangjie |
468 //Could look advanced cangjie as normal and easy cangjie |
483 else |
469 else |
484 { |
470 { |
485 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie); |
471 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie); |
487 start = 0; |
473 start = 0; |
488 for (TInt i =0; i < len; i++) |
474 for (TInt i =0; i < len; i++) |
489 { |
475 { |
490 if (wordInterpretationBuf[i] == KSeperator) |
476 if (wordInterpretationBuf[i] == KSeperator) |
491 { |
477 { |
492 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); |
478 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
493 aSpellList.AppendL(tmpStr); |
|
494 CleanupStack::Pop(tmpStr); |
|
495 start = i + 1; |
479 start = i + 1; |
496 } |
480 } |
497 } |
481 } |
498 |
482 |
499 HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); |
483 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
500 aSpellList.AppendL(tmpStr); |
484 |
501 CleanupStack::Pop(tmpStr); |
485 |
502 |
|
503 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie); |
486 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie); |
504 len = wordInterpretationBuf.Length(); |
487 len = wordInterpretationBuf.Length(); |
505 start = 0; |
488 start = 0; |
506 for (TInt i =0; i < len; i++) |
489 for (TInt i =0; i < len; i++) |
507 { |
490 { |
508 if (wordInterpretationBuf[i] == KSeperator) |
491 if (wordInterpretationBuf[i] == KSeperator) |
509 { |
492 { |
510 tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); |
493 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
511 aSpellList.AppendL(tmpStr); |
|
512 CleanupStack::Pop(tmpStr); |
|
513 start = i + 1; |
494 start = i + 1; |
514 } |
495 } |
515 } |
496 } |
516 |
497 |
517 tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); |
498 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
518 aSpellList.AppendL(tmpStr); |
|
519 CleanupStack::Pop(tmpStr); |
|
520 } |
499 } |
521 |
500 |
522 return ETrue; |
501 return ETrue; |
523 } |
502 } |
524 |
503 |
903 } |
882 } |
904 |
883 |
905 if (haschineseword) |
884 if (haschineseword) |
906 { |
885 { |
907 TInt ii=0; |
886 TInt ii=0; |
908 TBool leftDifferentChinese = EFalse; |
887 TBuf<KMaxWordLength> tmpBuf; |
909 //this is used for fixing for the issue of search string including Chinese characters |
888 tmpBuf.Zero(); |
|
889 |
|
890 ////translate the whole searchstring to spelllist |
910 while (ii< tempBuf.Length()) |
891 while (ii< tempBuf.Length()) |
911 { |
892 { |
|
893 |
|
894 //if it is a valid chinese character |
912 if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke |
895 if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke |
913 ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii])))) |
896 ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii])))) |
914 { |
897 { |
915 TInt Findcursor = itemString.Locate(tempBuf[ii]); |
898 |
916 if (Findcursor != KErrNotFound) |
899 RPointerArray<HBufC> spellList; |
917 { |
900 |
918 if ((Findcursor == itemString.Length()-1)&& (ii |
901 //translate the chinese charater to spellList( pinyin or stroke ) |
919 ==tempBuf.Length()-1)) |
902 if( DoTranslationL(TInt16(tempBuf[ii]), spellList) |
920 { |
903 && ( tmpBuf.Length() + spellList[0]->Length() < KMaxWordLength) ) |
921 |
904 { |
922 if ( leftDifferentChinese || IsChineseWord( |
905 tmpBuf.Append( spellList[0]->Des() ); |
923 itemString.Left( Findcursor ) ) ) |
|
924 { |
|
925 //if the different Chinese character at the left or middle, return false. |
|
926 return EFalse; |
|
927 } |
|
928 |
|
929 return ETrue; |
|
930 } |
|
931 itemString.Delete(0, Findcursor+1); |
|
932 tempBuf.Delete(0, ii+1); |
|
933 ii=0; |
|
934 } |
906 } |
935 else |
|
936 { |
|
937 |
907 |
938 if ( IsChineseWord( tempBuf.Left( ii + 1 ) ) ) |
908 spellList.ResetAndDestroy(); |
939 { |
909 spellList.Close(); |
940 //flag the different Chinese character at the left. |
910 ii++; |
941 leftDifferentChinese = ETrue; |
911 } |
942 } |
912 //if not, just append it |
|
913 else |
|
914 { |
|
915 if( tmpBuf.Length() + 1 < KMaxWordLength ) |
|
916 { |
|
917 tmpBuf.Append( tempBuf[ii] ); |
|
918 } |
943 |
919 |
944 ii++; |
|
945 } |
|
946 } |
|
947 else |
|
948 { |
|
949 ii++; |
920 ii++; |
950 } |
921 } |
951 } |
922 } |
|
923 |
|
924 tempBuf.Zero(); |
|
925 tempBuf.Copy(tmpBuf); |
952 } |
926 } |
953 |
927 |
954 // Array for item string |
928 // Array for item string |
955 RPointerArray<STRINGINFO> stringInfoArr; |
929 RPointerArray<STRINGINFO> stringInfoArr; |
956 // Split item string |
930 // Split item string |
1484 } |
1458 } |
1485 } |
1459 } |
1486 |
1460 |
1487 return IsChineseSearchStr; |
1461 return IsChineseSearchStr; |
1488 } |
1462 } |
|
1463 |
|
1464 // -------------------------------------------------------- |
|
1465 // Find pane text is just Chinese word |
|
1466 // -------------------------------------------------------- |
|
1467 // |
|
1468 TBool CFindUtilChinese::ChineseWord(const TDesC& aWord) |
|
1469 { |
|
1470 TBool isChineseWord = ETrue; |
|
1471 const TInt len = aWord.Length(); |
|
1472 |
|
1473 TBool InputMethodStroke = EFalse; |
|
1474 if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) |
|
1475 { |
|
1476 InputMethodStroke = ETrue; |
|
1477 } |
|
1478 |
|
1479 for( TInt i = 0; i < len; i++ ) |
|
1480 { |
|
1481 if( ( ( TInt )aWord[i] < KMinUnicodeHz ) || ( InputMethodStroke && IsStrokeSymbol(aWord[i]) ) ) |
|
1482 { |
|
1483 isChineseWord = EFalse; |
|
1484 break; |
|
1485 } |
|
1486 } |
|
1487 return isChineseWord; |
|
1488 } |
1489 |
1489 |
1490 // --------------------------------------------------------- |
1490 // --------------------------------------------------------- |
1491 // Find pane text is including stroke symbol |
1491 // Find pane text is including stroke symbol |
1492 // --------------------------------------------------------- |
1492 // --------------------------------------------------------- |
1493 // |
1493 // |
2332 } |
2328 } |
2333 else |
2329 else |
2334 { |
2330 { |
2335 //for multiphnetic spell |
2331 //for multiphnetic spell |
2336 TInt spellCount = tempSpellList.Count(); |
2332 TInt spellCount = tempSpellList.Count(); |
2337 |
2333 TInt matchMaxIndex = 0; |
|
2334 TInt matchMax = 0; |
|
2335 TInt matchMaxPre = 0; |
2338 // Search all spelling |
2336 // Search all spelling |
2339 for (TInt j = 0; j < spellCount; j++) |
2337 for (TInt j = 0; j < spellCount; j++) |
2340 { |
2338 { |
2341 //for multiphnetic spell |
2339 //for multiphnetic spell |
2342 TInt spellCount = tempSpellList.Count(); |
2340 TInt spellCount = tempSpellList.Count(); |