144 // CFindUtilChineseECE utils class |
116 // CFindUtilChineseECE utils class |
145 // --------------------------------------------------------- |
117 // --------------------------------------------------------- |
146 // |
118 // |
147 CFindUtilChineseECE::CFindUtilChineseECE() : |
119 CFindUtilChineseECE::CFindUtilChineseECE() : |
148 iLanguage(ELangTest), |
120 iLanguage(ELangTest), |
149 iSupportPRCChinese(EFalse), |
121 iCurInputMode(KSysInputMode), |
150 iCurInputMode(KSysInputMode) |
122 iSearchMethod(EAdptSearchPinyin), |
151 // The below code is commented out because current CFindUtilChineseECE is used |
|
152 // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code |
|
153 // for the further merging work (merge from FindUtil 5.0) |
|
154 #if 0 |
|
155 iSearchMethodPRC(EAdptSearchPinyin), |
|
156 iSearchMethodTaiWan(EAdptSearchZhuyin), |
|
157 iSearchMethodHongKong(EAdptSearchStroke), |
|
158 iSearchMethodAdaptive(EFalse) |
123 iSearchMethodAdaptive(EFalse) |
159 #endif |
124 { |
160 { |
125 } |
161 } |
|
162 |
126 |
163 // --------------------------------------------------------- |
127 // --------------------------------------------------------- |
164 // Destructor |
128 // Destructor |
165 // --------------------------------------------------------- |
129 // --------------------------------------------------------- |
166 // |
130 // |
167 CFindUtilChineseECE::~CFindUtilChineseECE() |
131 CFindUtilChineseECE::~CFindUtilChineseECE() |
168 { |
132 { |
169 delete iPtiEngine; |
133 delete iPtiEngine; |
170 delete iWatcher; |
134 delete iWatcher; |
171 delete iPtiEnginePrc; |
|
172 delete iRepositoryFind; |
135 delete iRepositoryFind; |
173 // The below code is commented out because current CFindUtilChineseECE is used |
|
174 // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code |
|
175 // for the further merging work (merge from FindUtil 5.0) |
|
176 #if 0 |
|
177 delete iWatcherAdaptive; |
136 delete iWatcherAdaptive; |
178 delete iRepositoryFindAdaptive; |
137 delete iRepositoryFindAdaptive; |
179 #endif |
|
180 } |
138 } |
181 |
139 |
182 // --------------------------------------------------------- |
140 // --------------------------------------------------------- |
183 // Open ptiengine and active it by input language |
141 // Open ptiengine and active it by input language |
184 // --------------------------------------------------------- |
142 // --------------------------------------------------------- |
387 |
356 |
388 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len - start)).Alloc()); |
357 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len - start)).Alloc()); |
389 |
358 |
390 return ETrue; |
359 return ETrue; |
391 } |
360 } |
392 |
361 #endif |
393 // The below code is commented out because current CFindUtilChineseECE is used |
362 |
394 // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code |
|
395 // for the further merging work (merge from FindUtil 5.0) |
|
396 #if 0 |
|
397 // --------------------------------------------------------- |
363 // --------------------------------------------------------- |
398 // Do translate for Chinese word |
364 // Do translate for Chinese word |
399 // --------------------------------------------------------- |
365 // --------------------------------------------------------- |
400 // |
366 // |
401 TBool CFindUtilChineseECE::T9ChineseTranslationAdaptiveL(TInt16 aHZUnicode, |
367 TBool CFindUtilChineseECE::T9ChineseTranslationAdaptiveL(TInt16 aHZUnicode, |
402 RPointerArray<HBufC>& aSpellList) |
368 RPointerArray<HBufC>& aSpellList) |
403 { |
369 { |
404 TBuf<KMaxWordInterpretationLen> wordInterpretationBuf; |
370 TBuf<KMaxWordInterpretationLen> wordInterpretationBuf; |
405 |
371 |
406 if ( iLanguage == ELangPrcChinese ) |
372 switch(iSearchMethod) |
407 { |
373 { |
408 if(iSearchMethodPRC == EAdptSearchPinyin) |
374 case EAdptSearchPinyin: |
409 { |
375 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) |
410 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) |
|
411 != KErrNone) |
376 != KErrNone) |
412 { |
377 { |
413 return EFalse; |
378 return EFalse; |
414 } |
379 } |
415 } |
380 break; |
416 else if(iSearchMethodPRC == EAdptSearchStroke) |
381 case EAdptSearchStroke: |
417 { |
382 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) |
418 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) |
|
419 != KErrNone) |
383 != KErrNone) |
420 { |
384 { |
421 return EFalse; |
385 return EFalse; |
422 } |
386 } |
423 } |
387 break; |
424 else |
388 case EAdptSearchZhuyin: |
425 { |
389 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiZhuyin) |
426 return EFalse; |
|
427 } |
|
428 |
|
429 } |
|
430 else if ( iLanguage == ELangTaiwanChinese ) |
|
431 { |
|
432 if(iSearchMethodTaiWan == EAdptSearchZhuyin) |
|
433 { |
|
434 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiZhuyin) |
|
435 != KErrNone) |
390 != KErrNone) |
436 { |
391 { |
437 return EFalse; |
392 return EFalse; |
438 } |
393 } |
439 } |
394 break; |
440 else if(iSearchMethodTaiWan == EAdptSearchStroke) |
395 case EAdptSearchNormalCangjie: |
441 { |
396 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) |
442 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) |
|
443 != KErrNone) |
397 != KErrNone) |
444 { |
398 { |
445 return EFalse; |
399 return EFalse; |
446 } |
400 } |
447 } |
401 break; |
448 else |
402 case EAdptSearchEasyCangjie: |
449 { |
403 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) |
450 return EFalse; |
404 != KErrNone) |
451 } |
405 { |
452 } |
406 return EFalse; |
453 else if ( iLanguage == ELangHongKongChinese ) |
407 } |
454 { |
408 break; |
455 switch(iSearchMethodHongKong) |
409 case EAdptSearchAdvCangjie: |
456 { |
410 if ((iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) != KErrNone) |
457 case EAdptSearchNormalCangjie: |
411 &&(iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) != KErrNone)) |
458 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) |
412 { |
459 != KErrNone) |
413 return EFalse; |
460 { |
414 } |
461 return EFalse; |
415 break; |
462 } |
416 default: |
463 break; |
|
464 case EAdptSearchEasyCangjie: |
|
465 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) |
|
466 != KErrNone) |
|
467 { |
|
468 return EFalse; |
|
469 } |
|
470 break; |
|
471 case EAdptSearchAdvCangjie: |
|
472 if ((iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) != KErrNone) |
|
473 &&(iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) != KErrNone)) |
|
474 { |
|
475 return EFalse; |
|
476 } |
|
477 break; |
|
478 case EAdptSearchStroke: |
|
479 if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) |
|
480 != KErrNone) |
|
481 { |
|
482 return EFalse; |
|
483 } |
|
484 break; |
|
485 default: |
|
486 return EFalse; |
|
487 } |
|
488 |
|
489 } |
|
490 else if ( iLanguage == ELangEnglish ) |
|
491 { |
|
492 if (!iSupportPRCChinese) |
|
493 { |
|
494 return EFalse; |
417 return EFalse; |
495 } |
418 } |
496 |
419 |
497 TInt err = KErrNone; |
|
498 if (!iPtiEnginePrc) |
|
499 { |
|
500 iPtiEnginePrc = CPtiEngine::NewL(EFalse); |
|
501 TRAP(err, iPtiEnginePrc->ActivateLanguageL(ELangPrcChinese)); |
|
502 } |
|
503 |
|
504 if (err == KErrNone) |
|
505 { |
|
506 if (iPtiEnginePrc->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) |
|
507 != KErrNone) |
|
508 |
|
509 return EFalse; |
|
510 } |
|
511 } |
|
512 else |
|
513 { |
|
514 return EFalse; |
|
515 } |
|
516 |
420 |
517 TInt len = wordInterpretationBuf.Length(); |
421 TInt len = wordInterpretationBuf.Length(); |
518 TInt start = 0; |
422 TInt start = 0; |
519 |
423 |
520 if( iSearchMethodHongKong != EAdptSearchAdvCangjie ) |
424 if( iSearchMethod != EAdptSearchAdvCangjie ) |
521 { |
425 { |
522 for (TInt i =0; i < len; i++) |
426 for (TInt i =0; i < len; i++) |
523 { |
427 { |
524 if (wordInterpretationBuf[i] == KSeperator) |
428 if (wordInterpretationBuf[i] == KSeperator) |
525 { |
429 { |
526 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
430 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); |
527 start = i + 1; |
431 start = i + 1; |
528 } |
432 } |
529 } |
433 } |
530 |
434 |
531 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
435 aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); |
532 } |
436 } |
533 //Could look advanced cangjie as normal and easy cangjie |
437 //Could look advanced cangjie as normal and easy cangjie |
534 else |
438 else |
535 { |
439 { |
536 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie); |
440 iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie); |
581 // --------------------------------------------------------- |
484 // --------------------------------------------------------- |
582 // |
485 // |
583 void CFindUtilChineseECE::OpenL() |
486 void CFindUtilChineseECE::OpenL() |
584 { |
487 { |
585 TInt inputLanguage = 0; |
488 TInt inputLanguage = 0; |
586 //TInt searchMode =0; |
489 TInt searchMode = 0; |
587 |
490 |
588 if (iRepositoryFind != NULL) |
491 if (iRepositoryFind != NULL) |
589 { |
492 { |
590 iRepositoryFind->Get(KAknFepInputTxtLang, inputLanguage); |
493 iRepositoryFind->Get(KAknFepInputTxtLang, inputLanguage); |
591 } |
494 } |
592 |
495 |
|
496 // The following sets iLangueage to inputLanguage if inputLanguage |
|
497 // is Chinese. If inputLanguage is non-Chinese, iLanguage will be |
|
498 // set to first available Chinese language. |
593 OpenT9InterfaceL((TLanguage) inputLanguage); |
499 OpenT9InterfaceL((TLanguage) inputLanguage); |
594 |
500 |
595 // The below code is commented out because current CFindUtilChineseECE is used |
|
596 // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code |
|
597 // for the further merging work (merge from FindUtil 5.0) |
|
598 #if 0 |
|
599 if (iRepositoryFindAdaptive != NULL) |
501 if (iRepositoryFindAdaptive != NULL) |
600 { |
502 { |
601 iRepositoryFindAdaptive->Get(KAknAvkonAdaptiveSearchEnabled, iSearchMethodAdaptive); |
503 iRepositoryFindAdaptive->Get(KAknAvkonAdaptiveSearchEnabled, iSearchMethodAdaptive); |
602 } |
504 } |
603 if( inputLanguage == ELangPrcChinese) |
505 if (iLanguage == ELangPrcChinese) |
604 { |
506 { |
605 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC , searchMode); |
507 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC , searchMode); |
606 if(searchMode ==0) |
508 if (searchMode == 0) |
607 { |
509 { |
608 iSearchMethodPRC = EAdptSearchPinyin; |
510 iSearchMethod = EAdptSearchPinyin; |
609 } |
511 } |
610 else if(searchMode ==1) |
512 else if (searchMode == 1) |
611 { |
513 { |
612 iSearchMethodPRC = EAdptSearchStroke; |
514 iSearchMethod = EAdptSearchStroke; |
613 } |
515 } |
614 } |
516 } |
615 else if(inputLanguage == ELangTaiwanChinese) |
517 else if (iLanguage == ELangTaiwanChinese) |
616 { |
518 { |
617 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseTW , searchMode); |
519 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseTW , searchMode); |
618 if(searchMode ==0) |
520 if (searchMode == 0) |
619 { |
521 { |
620 iSearchMethodTaiWan = EAdptSearchZhuyin; |
522 iSearchMethod = EAdptSearchZhuyin; |
621 } |
523 } |
622 else if(searchMode ==1) |
524 else if (searchMode == 1) |
623 { |
525 { |
624 iSearchMethodTaiWan = EAdptSearchStroke; |
526 iSearchMethod = EAdptSearchStroke; |
625 } |
527 } |
626 } |
528 } |
627 else if(inputLanguage == ELangHongKongChinese) |
529 else if (iLanguage == ELangHongKongChinese) |
628 { |
530 { |
629 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseHongkong , searchMode); |
531 iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseHongkong , searchMode); |
630 if(searchMode ==1) |
532 if (searchMode == 1) |
631 { |
533 { |
632 iRepositoryFind->Get(KAknFepCangJieMode , searchMode); |
534 iRepositoryFind->Get(KAknFepCangJieMode , searchMode); |
633 |
535 |
634 switch (searchMode) |
536 switch (searchMode) |
635 { |
537 { |
636 case 0: |
538 case 0: |
637 iSearchMethodHongKong = EAdptSearchNormalCangjie; |
539 iSearchMethod = EAdptSearchNormalCangjie; |
638 break; |
540 break; |
639 case 1: |
541 case 1: |
640 iSearchMethodHongKong = EAdptSearchEasyCangjie; |
542 iSearchMethod = EAdptSearchEasyCangjie; |
641 break; |
543 break; |
642 case 2: |
544 case 2: |
643 iSearchMethodHongKong = EAdptSearchAdvCangjie; |
545 iSearchMethod = EAdptSearchAdvCangjie; |
644 break; |
546 break; |
645 } |
547 } |
646 |
548 } |
647 } |
549 else if (searchMode == 0) |
648 else if(searchMode ==0) |
550 { |
649 { |
551 iSearchMethod = EAdptSearchStroke; |
650 iSearchMethodHongKong = EAdptSearchStroke; |
552 } |
651 } |
553 } |
652 |
|
653 } |
|
654 #endif |
|
655 } |
554 } |
656 |
555 |
657 // --------------------------------------------------------- |
556 // --------------------------------------------------------- |
658 // Close ptiEngine |
557 // Close ptiEngine |
659 // --------------------------------------------------------- |
558 // --------------------------------------------------------- |
910 } |
824 } |
911 else |
825 else |
912 { |
826 { |
913 iCurInputMode = KSysInputMode; |
827 iCurInputMode = KSysInputMode; |
914 } |
828 } |
915 |
829 |
916 // Check Chinese word in find pane |
830 TBool inputMethodStroke = EFalse; |
917 if (IsChineseWord(tempBuf)) |
831 if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) |
|
832 { |
|
833 inputMethodStroke = ETrue; |
|
834 } |
|
835 |
|
836 // Check if any Chinese word in find pane |
|
837 if ( IsChineseWordIncluded(tempBuf) ) |
918 { |
838 { |
919 haschineseword = ETrue; |
839 haschineseword = ETrue; |
920 ret = IncludeString(aItemString, tempBuf); |
840 ret = IncludeString(aItemString, tempBuf); |
921 |
841 |
922 if (ret) |
842 if( IsAllChineseWord( tempBuf )) |
923 { |
843 { |
|
844 CleanupStack::PopAndDestroy( query ); |
924 return ret; |
845 return ret; |
925 } |
846 } |
926 /* else |
847 } |
927 { |
848 |
928 // if Stroke Symbol in HongKong |
849 |
929 TBool strokeSymHK = (IsStrokeSymbolInString(tempBuf)) && |
850 // There are two steps to do when searchstring includes Chinese character |
930 (iLanguage == ELangHongKongChinese) && |
851 // |
931 iCurInputMode == 0x0020; |
852 // step 1: check whether itemstring includes the chinese charactor in the searchstring |
932 |
853 // If not, return EFalse. Otherwise, go to step2 |
933 if (!strokeSymHK) |
854 // |
934 { |
855 // step2: If itemstring includes the chinese charactor in the searchstring, translate |
935 return ret; |
856 // the Chinese character in the searchstring to spellList and reconstruct the query. |
936 } |
|
937 }*/ |
|
938 } |
|
939 |
|
940 //Find if search string has chinese word. |
|
941 //Compare with item string if find chinese word in item string then delete it from search and item string. |
|
942 //if not then return EFalse. |
|
943 TBool InputMethodStroke = EFalse; |
|
944 if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) |
|
945 { |
|
946 InputMethodStroke = ETrue; |
|
947 } |
|
948 |
|
949 if (haschineseword) |
857 if (haschineseword) |
950 { |
858 { |
951 TInt ii=0; |
859 TInt ii=0; |
952 TBool leftDifferentChinese = EFalse; //Fixed for ESSG-7PJ6GF, flag the different Chinese character at the left of aSearchText. |
860 |
|
861 // Step 1: |
|
862 // E.g: itemstring = "0x4E00,0x4E8C,0x4E09,0x56DB,0x4E94" |
|
863 // (Unicode of Chinese number "1 2 3 4 5") |
|
864 // searchstring1 = "0x4E00,x,y,z,0x4E09" |
|
865 // searchstring2 = "0x4E8C,0x4E00" |
|
866 // searchstring3 = "0x4E00,0x4E5D" |
|
867 // In this case, searchstring2 and searchstring3 will return EFalse, |
|
868 // only searchstring1 will be translated to spellList in step 2 |
953 while (ii< tempBuf.Length()) |
869 while (ii< tempBuf.Length()) |
954 { |
870 { |
955 if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke |
871 TInt lastFindCursor = -1; |
956 ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii])))) |
872 if( (TUint16)tempBuf[ii] <= KMaxUnicodeHz |
|
873 && (TUint16)tempBuf[ii]>= KMinUnicodeHz |
|
874 && ( !inputMethodStroke ||(inputMethodStroke && |
|
875 !IsStrokeSymbol(tempBuf[ii])) ) ) |
957 { |
876 { |
958 TInt Findcursor = itemString.Locate(tempBuf[ii]); |
877 TInt Findcursor = itemString.Locate(tempBuf[ii]); |
959 if (Findcursor != KErrNotFound) |
878 if( KErrNotFound == Findcursor || Findcursor < lastFindCursor ) |
960 { |
879 { |
961 if ((Findcursor == itemString.Length()-1)&& (ii |
880 CleanupStack::PopAndDestroy( query ); |
962 ==tempBuf.Length()-1)) |
881 return EFalse; |
963 { |
|
964 //Start:Fixed for ESSG-7PJ6GF |
|
965 if ( leftDifferentChinese || IsChineseWord( |
|
966 itemString.Left( Findcursor ) ) ) |
|
967 { |
|
968 //if the different Chinese character at the left or middle, return false. |
|
969 return EFalse; |
|
970 } |
|
971 //End:Fixed for ESSG-7PJ6GF |
|
972 return ETrue; |
|
973 } |
|
974 itemString.Delete(0, Findcursor+1); |
|
975 tempBuf.Delete(0, ii+1); |
|
976 ii=0; |
|
977 } |
882 } |
978 else |
883 else |
979 { |
884 { |
980 //Start:Fixed for ESSG-7PJ6GF |
885 lastFindCursor = Findcursor; |
981 if ( IsChineseWord( tempBuf.Left( ii + 1 ) ) ) |
|
982 { |
|
983 //flag the different Chinese character at the left. |
|
984 leftDifferentChinese = ETrue; |
|
985 } |
|
986 //End:Fixed for ESSG-7PJ6GF |
|
987 ii++; |
886 ii++; |
988 } |
887 } |
989 } |
888 } |
990 else |
889 else |
991 { |
890 { |
992 ii++; |
891 ii++; |
993 } |
892 } |
994 } |
893 } |
995 |
894 |
996 } |
895 ii = 0; |
997 |
896 // Counter of queryItem |
|
897 TInt queryItemCount = 0; |
|
898 |
|
899 //Step 2: |
|
900 // Translating searchstring to spellList and reconstruct query |
|
901 while ( ii< tempBuf.Length() ) |
|
902 { |
|
903 // If it is a valid chinese character |
|
904 if ( (TUint16)tempBuf[ii] <= KMaxUnicodeHz |
|
905 && (TUint16)tempBuf[ii]>= KMinUnicodeHz |
|
906 && ( !inputMethodStroke ||(inputMethodStroke && |
|
907 !IsStrokeSymbol(tempBuf[ii])) ) ) |
|
908 { |
|
909 RPointerArray<HBufC> spellList; |
|
910 |
|
911 // If successfully translating the chinese character to spellList( Pinyin,Zhuyin or stroke ) |
|
912 // then reconstruct the query, replace the Chinese character with its spellList in the query. |
|
913 // Otherwise, just increase the counter of queryItem. |
|
914 if( DoTranslationL(TInt16(tempBuf[ii]), spellList) ) |
|
915 { |
|
916 // Replace the queryItem by the translated spelling |
|
917 CPsQueryItem& tempItem = query->GetItemAtL(queryItemCount); |
|
918 const TKeyboardModes tempMode = tempItem.Mode(); |
|
919 |
|
920 // Remove the Chinese character queryItem |
|
921 query->Remove(queryItemCount); |
|
922 |
|
923 // Reconstruct the query, replace Chinese character with its spellList |
|
924 for(TInt cnt = 0; cnt < spellList[0]->Length(); cnt++) |
|
925 { |
|
926 // Add a new query item to query |
|
927 CPsQueryItem* newItem = CPsQueryItem::NewL(); |
|
928 CleanupStack::PushL(newItem); |
|
929 newItem->SetCharacter( (*spellList[0])[cnt] ); |
|
930 newItem->SetMode(tempMode); |
|
931 |
|
932 query->InsertL(*newItem, queryItemCount + cnt ); |
|
933 CleanupStack::Pop(newItem); |
|
934 } |
|
935 |
|
936 queryItemCount += spellList[0]->Length(); |
|
937 } |
|
938 else |
|
939 { |
|
940 queryItemCount++; |
|
941 } |
|
942 |
|
943 ii++; |
|
944 spellList.ResetAndDestroy(); |
|
945 spellList.Close(); |
|
946 |
|
947 } |
|
948 //if not, just pass it by |
|
949 else |
|
950 { |
|
951 ii++; |
|
952 queryItemCount++; |
|
953 } |
|
954 } |
|
955 |
|
956 } |
|
957 |
998 // Array for item string |
958 // Array for item string |
999 RPointerArray<STRINGINFO> stringInfoArr; |
959 RPointerArray<STRINGINFO> stringInfoArr; |
1000 // Split item string |
960 // Split item string |
1001 SplitItemStringL(stringInfoArr, itemString); |
961 SplitItemStringL(stringInfoArr, itemString); |
1002 |
962 |
1003 if (stringInfoArr.Count() > 0) |
963 if (stringInfoArr.Count() > 0) |
1004 { |
964 { |
1005 ret = MatchSegmentL(stringInfoArr, *query); |
965 ret = MatchSegmentL(stringInfoArr, *query, aMatchPos, aMatchLength, aHighLight); |
1006 } |
966 } |
1007 |
967 |
1008 stringInfoArr.ResetAndDestroy(); |
968 stringInfoArr.ResetAndDestroy(); |
1009 stringInfoArr.Close(); |
969 stringInfoArr.Close(); |
1010 |
970 |
1011 delete query; |
971 CleanupStack::PopAndDestroy( query ); |
1012 |
972 |
1013 return ret; |
973 return ret; |
1014 } |
974 } |
1015 |
975 |
1016 // --------------------------------------------------------- |
976 // --------------------------------------------------------- |
1017 // Splite the input text to sgement by language |
977 // Splite the input text to sgement by language |
1018 // --------------------------------------------------------- |
978 // --------------------------------------------------------- |
1019 // |
979 // |
1020 void CFindUtilChineseECE::SplitItemStringL(RPointerArray<STRINGINFO>& aStringInfoArr, |
980 void CFindUtilChineseECE::SplitItemStringL(RPointerArray<STRINGINFO>& aStringInfoArr, |
1021 const TDesC &aItemString) |
981 const TDesC& aItemString) |
1022 { |
982 { |
1023 TBuf<KMaxWordLength> tempBuf; |
983 TBuf<KMaxWordLength> tempBuf; |
1024 TBuf<KMaxWordLength> englishBuf; |
984 TBuf<KMaxWordLength> englishBuf; |
1025 TBuf<KMaxWordLength> chineseBuf; |
985 TBuf<KMaxWordLength> chineseBuf; |
1026 |
986 |
1027 tempBuf.Zero(); |
987 tempBuf.Zero(); |
1028 englishBuf.Zero(); |
988 englishBuf.Zero(); |
1029 chineseBuf.Zero(); |
989 chineseBuf.Zero(); |
1030 |
990 |
1031 TInt index = 0; |
991 TInt index = 0; |
1032 TUint32 temp = 0; |
992 TBool isChinese = EFalse; |
1033 TInt32 distance = 0; |
|
1034 const TInt strLength = aItemString.Length(); |
993 const TInt strLength = aItemString.Length(); |
1035 |
994 |
1036 for (; index < strLength; index++) |
995 for (; index < strLength; index++) |
1037 { |
996 { |
1038 if (IsFindWordSeparator(aItemString[index])) |
997 if (IsFindWordSeparator(aItemString[index])) |
1039 { |
998 { |
1040 // Check Chinese and English Buf. If it is not empty, |
999 // Check Chinese and English Buf. If it is not empty, |
1041 // add buf to Array |
1000 // add buf to Array |
1042 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); |
1001 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); |
1043 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); |
1002 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); |
1044 continue; |
1003 continue; |
1045 } |
1004 } |
1046 |
1005 |
1047 temp = aItemString[index]; |
1006 isChinese = ((TUint16)aItemString[index] >= KMinUnicodeHz && |
1048 distance = (TInt32)(temp - KMinUnicodeHz); |
1007 (TUint16)aItemString[index] <= KMaxUnicodeHz); |
1049 |
1008 |
1050 if (distance < 0)// English word |
1009 if ( !isChinese )// English word |
1051 { |
1010 { |
1052 // Chinese word is end and add to array |
1011 // Chinese word is end and add to array |
1053 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); |
1012 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); |
1054 |
1013 |
1055 // Add English word to array |
1014 // Add English word to array |
1056 englishBuf.Append((TChar) aItemString[index]); |
1015 englishBuf.Append(aItemString[index]); |
1057 } |
1016 } |
1058 else // Chinese word |
1017 else // Chinese word |
1059 { |
1018 { |
1060 // English word is end and add to array |
1019 // English word is end and add to array |
1061 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); |
1020 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); |
1062 |
1021 |
1063 // Add Chinese word to array |
1022 // Add Chinese word to array |
1064 chineseBuf.Append((TChar) aItemString[index]); |
1023 chineseBuf.Append(aItemString[index]); |
1065 } |
1024 } |
1066 } |
1025 } |
1067 |
1026 |
1068 // Finish loop check buffer is empty |
1027 // Finish loop check buffer is empty |
1069 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); |
1028 InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); |
1070 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); |
1029 InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); |
1071 } |
1030 } |
1072 |
1031 |
1073 // --------------------------------------------------------- |
1032 // --------------------------------------------------------- |
1074 // Insert segment to list |
1033 // Insert segment to list |
1075 // --------------------------------------------------------- |
1034 // --------------------------------------------------------- |
1076 // |
1035 // |
1077 void CFindUtilChineseECE::InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr, |
1036 void CFindUtilChineseECE::InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr, |
1078 TDes &aSegmentStr, const TBool aChinese) |
1037 TDes &aSegmentStr, TBool aChinese, TInt aIndexAfterStr) |
1079 { |
1038 { |
1080 CleanupResetAndDestroyPushL( aStringInfoArr ); |
|
1081 if (aSegmentStr.Length() <= 0) |
1039 if (aSegmentStr.Length() <= 0) |
1082 { |
1040 { |
1083 return; |
1041 return; |
1084 } |
1042 } |
1085 |
1043 |
1087 |
1045 |
1088 strInfo->segmentString.Zero(); |
1046 strInfo->segmentString.Zero(); |
1089 strInfo->segmentString.Copy(aSegmentStr); |
1047 strInfo->segmentString.Copy(aSegmentStr); |
1090 strInfo->segmentString.LowerCase(); |
1048 strInfo->segmentString.LowerCase(); |
1091 strInfo->isChinese = aChinese; |
1049 strInfo->isChinese = aChinese; |
|
1050 strInfo->segmentPos = aIndexAfterStr - aSegmentStr.Length(); |
1092 |
1051 |
1093 aStringInfoArr.AppendL(strInfo); |
1052 aStringInfoArr.AppendL(strInfo); |
1094 aSegmentStr.Zero(); |
1053 aSegmentStr.Zero(); |
1095 CleanupStack::Pop( &aStringInfoArr ); |
|
1096 } |
1054 } |
1097 |
1055 |
1098 // --------------------------------------------------------- |
1056 // --------------------------------------------------------- |
1099 // This segment is matched by search text |
1057 // This segment is matched by search text |
1100 // --------------------------------------------------------- |
1058 // --------------------------------------------------------- |
1101 // |
1059 // |
1102 TBool CFindUtilChineseECE::MatchSegmentL(RPointerArray<STRINGINFO>& aStringInfoArr, |
1060 TBool CFindUtilChineseECE::MatchSegmentL(RPointerArray<STRINGINFO>& aStringInfoArr, |
1103 CPsQuery& aQuery) |
1061 CPsQuery& aQuery, RArray<TInt>& aMatchPos, RArray<TInt>& aMatchLength, TBool aHighLight ) |
1104 { |
1062 { |
1105 const TInt arrayLength = aStringInfoArr.Count(); |
1063 const TInt arrayLength = aStringInfoArr.Count(); |
1106 const TInt searchStrLength = aQuery.Count(); |
1064 const TInt searchStrLength = aQuery.Count(); |
1107 TInt searchStrIndex = 0; |
|
1108 STRINGINFO* pStringInfo; |
1065 STRINGINFO* pStringInfo; |
1109 TInt index = 0; |
1066 TInt index = 0; |
1110 |
1067 TBool ret = EFalse; |
1111 // First only check English |
1068 TBool hasChinese = EFalse; |
|
1069 |
|
1070 // First check if there is a full match in non-Chinese in any one segment |
1112 for (; index < arrayLength; index++) |
1071 for (; index < arrayLength; index++) |
|
1072 { |
|
1073 pStringInfo = aStringInfoArr[index]; |
|
1074 TPtrC currentSeg( pStringInfo->segmentString ); |
|
1075 TInt matchLen( 0 ); |
|
1076 |
|
1077 // Compare word |
|
1078 if (pStringInfo->isChinese) |
|
1079 { |
|
1080 hasChinese = ETrue; |
|
1081 } |
|
1082 else |
|
1083 { |
|
1084 matchLen = MatchStringL( currentSeg, aQuery ); |
|
1085 } |
|
1086 |
|
1087 // If full match is found |
|
1088 if ( matchLen == searchStrLength ) |
|
1089 { |
|
1090 //Only append postion of non-Chinese character |
|
1091 if( !pStringInfo->isChinese ) |
|
1092 { |
|
1093 aMatchPos.Append( pStringInfo->segmentPos ); |
|
1094 aMatchLength.Append( matchLen ); |
|
1095 } |
|
1096 ret = ETrue; |
|
1097 |
|
1098 // If there is no need to HighLight the matched part, return immediately |
|
1099 // Otherwise, continue to find all the matched positions |
|
1100 if( !aHighLight ) |
|
1101 return ret; |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 // Then search through segments again, this time considering |
|
1106 // also cases where matching part continues over several segments. |
|
1107 // This algorithm is greedy and heuristic and can't necesarily find |
|
1108 // all the matches in the segments after the first one. |
|
1109 TPtrC segCurrent; |
|
1110 TInt searchStrIndextemp = 0; |
|
1111 TInt searchStrIndexMax = 0; |
|
1112 TInt searchStrIndex = 0; |
|
1113 index = 0; |
|
1114 |
|
1115 // Loop through seqments until whole query is matched |
|
1116 for (; index < arrayLength && !ret ; index++) |
1113 { |
1117 { |
1114 // Create an empty CPsQuery |
1118 // Create an empty CPsQuery |
1115 CPsQuery* tempQuery = CPsQuery::NewL(); |
1119 CPsQuery* tempQuery = CPsQuery::NewL(); |
|
1120 CleanupStack::PushL( tempQuery ); |
|
1121 |
|
1122 GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, *tempQuery ); |
|
1123 |
1116 pStringInfo = aStringInfoArr[index]; |
1124 pStringInfo = aStringInfoArr[index]; |
1117 |
1125 segCurrent.Set( pStringInfo->segmentString ); |
1118 GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, |
1126 |
1119 *tempQuery ); |
1127 if (pStringInfo->isChinese) |
1120 |
1128 { |
1121 // Compare word |
1129 // find the longest substring matching the query |
1122 if (!pStringInfo->isChinese) |
1130 searchStrIndexMax = 0; |
1123 { |
1131 for (TInt i = 0; i< segCurrent.Length(); i++) |
1124 searchStrIndex += MatchString(pStringInfo->segmentString, *tempQuery); |
1132 { |
1125 } |
1133 TPtrC tempSeg( segCurrent.Mid(i) ); |
1126 |
1134 TInt startIdx( KErrNotFound ); |
1127 delete tempQuery; |
1135 TInt endIdx( KErrNotFound ); |
1128 tempQuery = NULL; |
1136 searchStrIndextemp = MatchChineseStringL(tempSeg, *tempQuery, startIdx, endIdx); |
1129 |
1137 if (searchStrIndextemp > searchStrIndexMax) |
1130 if (searchStrIndex >= searchStrLength) |
|
1131 { |
|
1132 return ETrue; |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 TBuf<KMaxWordLength> bufcurrent; |
|
1137 TBuf<KMaxWordLength> tempbufcurrent; |
|
1138 TInt searchStrIndextemp = 0; |
|
1139 TInt searchStrIndexMax = 0; |
|
1140 // Find Chinese and English |
|
1141 searchStrIndex = 0; |
|
1142 index = 0; |
|
1143 |
|
1144 for (; index < arrayLength; index++) |
|
1145 { |
|
1146 // Create an empty CPsQuery |
|
1147 CPsQuery* tempQuery = CPsQuery::NewL(); |
|
1148 pStringInfo = aStringInfoArr[index]; |
|
1149 |
|
1150 GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, |
|
1151 *tempQuery ); |
|
1152 searchStrIndexMax = 0; |
|
1153 |
|
1154 bufcurrent = pStringInfo->segmentString; |
|
1155 |
|
1156 for(TInt i =0;i< pStringInfo->segmentString.Length();i++) |
|
1157 { |
|
1158 tempbufcurrent = bufcurrent.Mid(i); |
|
1159 if (pStringInfo->isChinese) |
|
1160 { |
|
1161 TInt temp=0; |
|
1162 searchStrIndextemp = MatchChineseStringL(tempbufcurrent, *tempQuery, temp); |
|
1163 if(searchStrIndextemp > searchStrIndexMax) |
|
1164 { |
1138 { |
1165 searchStrIndex -= searchStrIndexMax; |
1139 searchStrIndex -= searchStrIndexMax; |
1166 searchStrIndexMax = searchStrIndextemp; |
1140 searchStrIndexMax = searchStrIndextemp; |
1167 searchStrIndex += searchStrIndexMax; |
1141 searchStrIndex += searchStrIndexMax; |
1168 } |
1142 } |
1169 } |
1143 |
1170 else |
1144 if (searchStrIndex >= searchStrLength) |
1171 { |
1145 { |
1172 searchStrIndex += MatchString(pStringInfo->segmentString, *tempQuery); |
1146 // found substring which consumes whole query, no need to find any longer |
1173 } |
1147 break; |
1174 |
1148 } |
1175 if (searchStrIndex >= searchStrLength) |
1149 } |
1176 { |
1150 } |
1177 delete tempQuery; |
1151 else // not chinese |
1178 tempQuery = NULL; |
1152 { |
1179 return ETrue; |
1153 TInt matchLen = MatchStringL(segCurrent, *tempQuery); |
1180 } |
1154 searchStrIndex += matchLen; |
1181 else if(!pStringInfo->isChinese) |
1155 if ( matchLen ) |
1182 { |
1156 { |
1183 break; |
1157 aMatchPos.Append( pStringInfo->segmentPos ); |
1184 } |
1158 aMatchLength.Append( matchLen ); |
1185 } |
1159 } |
1186 |
1160 } |
1187 delete tempQuery; |
1161 |
1188 tempQuery = NULL; |
1162 if (searchStrIndex >= searchStrLength) |
1189 } |
1163 { |
1190 |
1164 ret = ETrue; // also breaks us out from the loop |
1191 return EFalse; |
1165 } |
|
1166 else if ( !pStringInfo->isChinese && !hasChinese ) |
|
1167 { |
|
1168 CleanupStack::PopAndDestroy( tempQuery ); |
|
1169 break; |
|
1170 } |
|
1171 |
|
1172 CleanupStack::PopAndDestroy( tempQuery ); |
|
1173 } |
|
1174 |
|
1175 return ret; |
1192 } |
1176 } |
1193 |
1177 |
1194 // --------------------------------------------------------- |
1178 // --------------------------------------------------------- |
1195 // Search Chinese word in input text |
1179 // Search Chinese word in input text |
1196 // --------------------------------------------------------- |
1180 // --------------------------------------------------------- |
1197 // |
1181 // |
1198 TInt CFindUtilChineseECE::MatchChineseStringL(const TDesC& aSearhTargetString, CPsQuery& aQuery, TInt& aIndex) |
1182 TInt CFindUtilChineseECE::MatchChineseStringL(const TDesC& aSearhTargetString, CPsQuery& aQuery, |
|
1183 TInt& aMatchStartIdx, TInt& aMatchEndIdx) |
1199 { |
1184 { |
1200 const TInt stringLength = aSearhTargetString.Length(); |
1185 const TInt stringLength = aSearhTargetString.Length(); |
1201 const TInt searchLength = aQuery.Count(); |
1186 const TInt searchLength = aQuery.Count(); |
1202 TInt index = 0; |
1187 TInt index = 0; |
1203 //TBuf<KMaxWordLength> tempBuf; |
|
1204 TBuf<KMaxWordLength> previousBuf; |
1188 TBuf<KMaxWordLength> previousBuf; |
1205 TInt curMatchCount = 0; |
1189 TInt curMatchCount = 0; |
1206 TInt preMatchCount = 0; |
1190 TInt preMatchCount = 0; |
1207 TInt matchIndex = 0; |
1191 TInt matchIndex = 0; |
1208 TInt curSearchIndex = 0; |
1192 TInt curSearchIndex = 0; |
1209 TBool bFullMatched = EFalse; |
1193 TBool bFullMatched = EFalse; |
1210 TBool bContinue = EFalse; |
1194 TBool bContinue = EFalse; |
|
1195 TBool bPrevReplaced = EFalse; |
|
1196 aMatchStartIdx = KErrNotFound; |
|
1197 aMatchEndIdx = KErrNotFound; |
|
1198 |
|
1199 CPsQuery* tempFullQuery = CPsQuery::NewL(); |
|
1200 CleanupStack::PushL( tempFullQuery ); |
|
1201 GetPartOfQueryL( aQuery, 0, aQuery.Count() - 1, *tempFullQuery ); |
1211 |
1202 |
1212 for (; index < stringLength; index++) |
1203 for (; index < stringLength; index++) |
1213 { |
1204 { |
1214 RPointerArray<HBufC> spellList; |
1205 RPointerArray<HBufC> spellList; |
1215 |
1206 |
1453 |
1461 |
1454 // --------------------------------------------------------- |
1462 // --------------------------------------------------------- |
1455 // Search text in other text |
1463 // Search text in other text |
1456 // --------------------------------------------------------- |
1464 // --------------------------------------------------------- |
1457 // |
1465 // |
1458 TInt CFindUtilChineseECE::MatchString(const TDesC& aFirst, const TDesC& aSecond) |
1466 TInt CFindUtilChineseECE::MatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery) |
1459 { |
1467 { |
1460 const TInt secondStrLength = aSecond.Length(); |
1468 const TInt secondStrLength = aSecond.Length(); |
1461 const TInt firstStrLength = aFirst.Length(); |
1469 const TInt firstStrLength = aFirst.Length(); |
1462 |
1470 |
1463 const TInt compareCount = firstStrLength > secondStrLength ? secondStrLength |
1471 const TInt compareCount = Min( firstStrLength, secondStrLength ); |
1464 : firstStrLength; |
|
1465 TInt index = 0; |
1472 TInt index = 0; |
1466 |
1473 TBuf<KMaxWordInterpretationLen> firstNumInterpretationBuf; |
1467 TBuf<KMaxWordLength> tempStr; |
1474 TBuf<KMaxWordInterpretationLen> secondNumInterpretationBuf; |
1468 // translate search target string into numeric string before match |
1475 |
1469 if (iAlgorithm) |
1476 iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aFirst, firstNumInterpretationBuf); |
1470 { |
1477 iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aSecond, secondNumInterpretationBuf); |
1471 iAlgorithm->Converter( aFirst, tempStr ); |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 tempStr.Copy(aFirst); |
|
1476 } |
|
1477 |
1478 |
1478 for (; index < compareCount; index++) |
1479 for (; index < compareCount; index++) |
1479 { |
1480 { |
1480 if (tempStr.Left(index + 1).FindC(aSecond.Left(index + 1)) == KErrNotFound) |
1481 if (firstNumInterpretationBuf.Left(index + 1).FindC(secondNumInterpretationBuf.Left(index + 1)) == KErrNotFound) |
1481 { |
1482 { |
1482 break; |
1483 break; |
1483 } |
1484 } |
1484 } |
1485 } |
1485 // Match count |
1486 // Match count |
1486 return index; |
1487 return index; |
1487 } |
1488 } |
|
1489 |
1488 // --------------------------------------------------------- |
1490 // --------------------------------------------------------- |
1489 // Search CPsQuery in aSearhTargetStr |
1491 // Search CPsQuery in aSearhTargetStr |
1490 // --------------------------------------------------------- |
1492 // --------------------------------------------------------- |
1491 // |
1493 // |
1492 TInt CFindUtilChineseECE::MatchString(const TDesC& aSearhTargetStr, CPsQuery& aQuery) |
1494 TInt CFindUtilChineseECE::MatchStringL(const TDesC& aSearhTargetStr, CPsQuery& aQuery) |
1493 { |
1495 { |
1494 const TInt secondStrLength = aQuery.Count(); |
1496 const TInt secondStrLength = aQuery.Count(); |
1495 const TInt firstStrLength = aSearhTargetStr.Length(); |
1497 const TInt firstStrLength = aSearhTargetStr.Length(); |
1496 TBuf<KMaxWordInterpretationLen> numInterpretationBuf; |
1498 TBuf<KMaxWordInterpretationLen> numInterpretationBuf; |
1497 |
1499 TBuf<KMaxWordInterpretationLen> queryStr; |
1498 const TInt compareCount = firstStrLength > secondStrLength ? secondStrLength |
1500 |
1499 : firstStrLength; |
1501 const TInt compareCount = Min( firstStrLength, secondStrLength ); |
|
1502 |
1500 TInt index = 0; |
1503 TInt index = 0; |
1501 |
1504 |
1502 ConvertdDataToKeyBoardModeL(aQuery, aSearhTargetStr, numInterpretationBuf); |
1505 iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aQuery, aSearhTargetStr, numInterpretationBuf); |
1503 |
1506 iAlgorithm->GetKeyMap()->GetMixedKeyStringForQueryL(aQuery, queryStr); |
1504 TPtrC queryStr = aQuery.QueryAsStringLC(); |
1507 |
1505 for (; index < compareCount; index++) |
1508 for (; index < compareCount; index++) |
1506 { |
1509 { |
1507 |
|
1508 if (numInterpretationBuf.Left(index + 1).FindC(queryStr.Left(index + 1)) == KErrNotFound) |
1510 if (numInterpretationBuf.Left(index + 1).FindC(queryStr.Left(index + 1)) == KErrNotFound) |
1509 { |
1511 { |
1510 break; |
1512 break; |
1511 } |
1513 } |
1512 } |
1514 } |
1513 CleanupStack::PopAndDestroy(); |
|
1514 |
1515 |
1515 // Match count |
1516 // Match count |
1516 return index; |
1517 return index; |
1517 } |
1518 } |
1518 |
1519 |
1519 // --------------------------------------------------------- |
1520 // --------------------------------------------------------- |
1520 // Search text by reverse |
1521 // Search text by reverse |
1521 // --------------------------------------------------------- |
1522 // --------------------------------------------------------- |
1522 // |
1523 // |
1523 TInt CFindUtilChineseECE::ReverseMatchString(const TDesC& aFirst, const TDesC& aSecond) |
1524 TInt CFindUtilChineseECE::ReverseMatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery) |
1524 { |
1525 { |
1525 const TInt secondStrLength = aSecond.Length(); |
1526 const TInt secondStrLength = aSecond.Length(); |
1526 const TInt firstStrLength = aFirst.Length(); |
1527 const TInt firstStrLength = aFirst.Length(); |
1527 TInt compareCount = firstStrLength > secondStrLength ? secondStrLength : firstStrLength; |
1528 TInt compareCount = firstStrLength > secondStrLength ? secondStrLength : firstStrLength; |
1528 TInt index = 0; |
1529 TInt index = 0; |
1529 TInt matchCount = 0; |
1530 TInt matchCount = 0; |
1530 |
1531 TBuf<KMaxWordInterpretationLen> firstNumInterpretationBuf; |
|
1532 TBuf<KMaxWordInterpretationLen> secondNumInterpretationBuf; |
|
1533 |
|
1534 iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aFirst, firstNumInterpretationBuf); |
|
1535 iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aSecond, secondNumInterpretationBuf); |
|
1536 |
1531 for (; index < compareCount; index++) |
1537 for (; index < compareCount; index++) |
1532 { |
1538 { |
1533 TBuf<KMaxWordLength> firstConvStr; |
1539 if( firstNumInterpretationBuf.Right( index + 1 ).FindC( secondNumInterpretationBuf.Left( index + 1 ) ) != KErrNotFound ) |
1534 TBuf<KMaxWordLength> secondConvStr; |
|
1535 |
|
1536 // translate compared target string into numeric string before match |
|
1537 if ( iAlgorithm ) |
|
1538 { |
|
1539 iAlgorithm->Converter( aFirst, firstConvStr ); |
|
1540 iAlgorithm->Converter( aSecond, secondConvStr ); |
|
1541 } |
|
1542 else |
|
1543 { |
|
1544 firstConvStr.Copy( aFirst ); |
|
1545 secondConvStr.Copy( aSecond ); |
|
1546 } |
|
1547 |
|
1548 if( firstConvStr.Right( index + 1 ).FindC( secondConvStr.Left( index + 1 ) ) != KErrNotFound ) |
|
1549 { |
1540 { |
1550 matchCount = index + 1; |
1541 matchCount = index + 1; |
1551 } |
1542 } |
1552 } |
1543 } |
1553 |
1544 |
1641 // --------------------------------------------------------- |
1661 // --------------------------------------------------------- |
1642 // |
1662 // |
1643 TInt CFindUtilChineseECE::HandleFindRepositoryCallBack(TAny* aPtr) |
1663 TInt CFindUtilChineseECE::HandleFindRepositoryCallBack(TAny* aPtr) |
1644 { |
1664 { |
1645 TInt ret = KErrNone; |
1665 TInt ret = KErrNone; |
1646 CFindUtilChineseECE *self = static_cast<CFindUtilChineseECE*> (aPtr); |
1666 CFindUtilChineseECE* self = static_cast<CFindUtilChineseECE*> (aPtr); |
1647 TInt searchMode = 0; |
1667 |
1648 |
1668 // Get changed key either from language repository (AknFepRepository) |
1649 if (self->iWatcher->ChangedKey() == KAknFepInputTxtLang) |
1669 // or from adaptive repository (AvkonRepository). |
1650 { |
1670 TUint32 changedKey = self->iWatcher->ChangedKey(); |
1651 TInt inputLanguage = 0; |
1671 if ( changedKey == NCentralRepositoryConstants::KInvalidNotificationId ) |
1652 self->iRepositoryFind->Get(KAknFepInputTxtLang, inputLanguage); |
1672 { |
1653 |
1673 changedKey = self->iWatcherAdaptive->ChangedKey(); |
1654 TInt prevCategory = self->CategoryOfLang(self->iLanguage); |
1674 } |
1655 TRAP(ret, self->OpenT9InterfaceL(TLanguage(inputLanguage))); |
1675 |
1656 |
1676 |
1657 TInt category = self->CategoryOfLang(TLanguage(inputLanguage)); |
1677 // Update the search method if input language or any search method variable |
1658 if (prevCategory != category && category != 0) |
1678 // changed |
|
1679 if ( changedKey == KAknFepInputTxtLang || |
|
1680 changedKey == KAknAdaptiveSearchChinesePRC || |
|
1681 changedKey == KAknAdaptiveSearchChineseTW || |
|
1682 changedKey == KAknAdaptiveSearchChineseHongkong || |
|
1683 changedKey == KAknFepCangJieMode || |
|
1684 changedKey == KAknAvkonAdaptiveSearchEnabled ) |
|
1685 { |
|
1686 TChineseSearchMethod prevSearchMethods = self->iSearchMethod; |
|
1687 |
|
1688 TRAP( ret, self->OpenL() ); |
|
1689 |
|
1690 // Reconstruct cache if search method got changed |
|
1691 if ( ret == KErrNone && prevSearchMethods != self->iSearchMethod ) |
1659 { |
1692 { |
1660 TRAP(ret, self->iAlgorithm->ReconstructCacheDataL()); |
1693 TRAP(ret, self->iAlgorithm->ReconstructCacheDataL()); |
1661 } |
1694 } |
1662 } |
1695 } |
1663 |
1696 |
1664 // The below code is commented out because current CFindUtilChineseECE is used |
|
1665 // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code |
|
1666 // for the further merging work (merge from FindUtil 5.0) |
|
1667 #if 0 |
|
1668 if(self->iWatcherAdaptive->ChangedKey() == KAknAvkonAdaptiveSearchEnabled) |
|
1669 { |
|
1670 self->iRepositoryFindAdaptive->Get(KAknAvkonAdaptiveSearchEnabled, self->iSearchMethodAdaptive); |
|
1671 } |
|
1672 |
|
1673 if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChinesePRC) |
|
1674 { |
|
1675 self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC, searchMode); |
|
1676 |
|
1677 if(searchMode ==0) |
|
1678 { |
|
1679 self->iSearchMethodPRC = EAdptSearchPinyin; |
|
1680 } |
|
1681 else if(searchMode ==1) |
|
1682 { |
|
1683 self->iSearchMethodPRC = EAdptSearchStroke; |
|
1684 } |
|
1685 } |
|
1686 |
|
1687 if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChineseTW ) |
|
1688 { |
|
1689 self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseTW , searchMode); |
|
1690 |
|
1691 if(searchMode ==0) |
|
1692 { |
|
1693 self->iSearchMethodTaiWan = EAdptSearchZhuyin; |
|
1694 } |
|
1695 else if(searchMode ==1) |
|
1696 { |
|
1697 self->iSearchMethodTaiWan = EAdptSearchStroke; |
|
1698 } |
|
1699 } |
|
1700 |
|
1701 if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChineseHongkong ) |
|
1702 { |
|
1703 self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseHongkong , searchMode); |
|
1704 |
|
1705 if(searchMode ==1) |
|
1706 { |
|
1707 self->iRepositoryFind->Get(KAknFepCangJieMode , searchMode); |
|
1708 |
|
1709 switch (searchMode) |
|
1710 { |
|
1711 case 0: |
|
1712 self->iSearchMethodHongKong = EAdptSearchNormalCangjie; |
|
1713 break; |
|
1714 case 1: |
|
1715 self->iSearchMethodHongKong = EAdptSearchEasyCangjie; |
|
1716 break; |
|
1717 case 2: |
|
1718 self->iSearchMethodHongKong = EAdptSearchAdvCangjie; |
|
1719 break; |
|
1720 } |
|
1721 |
|
1722 } |
|
1723 else if(searchMode ==0) |
|
1724 { |
|
1725 self->iSearchMethodHongKong = EAdptSearchStroke; |
|
1726 } |
|
1727 } |
|
1728 |
|
1729 if (self->iWatcher->ChangedKey() == KAknFepCangJieMode ) |
|
1730 { |
|
1731 self->iRepositoryFind->Get(KAknFepCangJieMode , searchMode); |
|
1732 |
|
1733 switch (searchMode) |
|
1734 { |
|
1735 case 0: |
|
1736 self->iSearchMethodHongKong = EAdptSearchNormalCangjie; |
|
1737 break; |
|
1738 case 1: |
|
1739 self->iSearchMethodHongKong = EAdptSearchEasyCangjie; |
|
1740 break; |
|
1741 case 2: |
|
1742 self->iSearchMethodHongKong = EAdptSearchAdvCangjie; |
|
1743 break; |
|
1744 } |
|
1745 |
|
1746 } |
|
1747 #endif |
|
1748 return ret; |
1697 return ret; |
1749 } |
1698 } |
1750 |
1699 |
1751 // --------------------------------------------------------- |
1700 // --------------------------------------------------------- |
1752 // Update input method in ptiengine from find pane |
1701 // Update input method in ptiengine from find pane |