diff -r 2666d9724c76 -r d4f567ce2e7c predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp --- a/predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp Thu Jul 15 18:22:55 2010 +0300 +++ b/predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp Thu Aug 19 09:41:07 2010 +0300 @@ -20,11 +20,12 @@ #include #include #include +#include + // The below code is commented out because current CFindUtilChineseECE is used // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code // for the further merging work (merge from FindUtil 5.0) #if 0 -#include #include //phonebook #include #include @@ -45,12 +46,13 @@ const TUint16 KZhuyinstart = 0x3105; const TInt KZhuyincount = 37; const TInt KSeperator = 2626; -const TInt16 KMinUnicodeHz = 0x4e00; -const TInt16 KStrokeHorizontalValue = 0x4e00; -const TInt16 KStrokeVerticalValue = 0x4e28; -const TInt16 KStrokeDownToLeftValue = 0x4e3f; -const TInt16 KStrokeDownToRightValue = 0x4e36; -const TInt16 KStrokeBendingValue = 0x4e5b; +const TUint16 KMinUnicodeHz = 0x4e00; +const TUint16 KMaxUnicodeHz = 0x9fa5; +const TUint16 KStrokeHorizontalValue = 0x4e00; +const TUint16 KStrokeVerticalValue = 0x4e28; +const TUint16 KStrokeDownToLeftValue = 0x4e3f; +const TUint16 KStrokeDownToRightValue = 0x4e36; +const TUint16 KStrokeBendingValue = 0x4e5b; const TInt KSysInputMode = -1; const TInt KLeftToRightFlag =0x200e; const TInt KRightToLeftFlag =0x200f; @@ -62,6 +64,7 @@ const TUid KUidPhoneBookServer = {0x10207277}; #endif + _LIT(KWildChar, "*"); _LIT(KUnderLine, "_"); _LIT(KMiddleLine, "-"); @@ -70,28 +73,6 @@ _LIT(KPanicReason, "Abnormal input parameters!"); const TInt KLitLineFeed(8233); - -// CleanupStack helpers for item owning RPointerArrays -template -class CleanupResetAndDestroy - { -public: - inline static void PushL( T& aRef ) - { - CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); - } -private: - inline static void ResetAndDestroy( TAny *aPtr ) - { - static_cast( aPtr )->ResetAndDestroy(); - } - }; - -template -inline void CleanupResetAndDestroyPushL( T& aRef ) - { - CleanupResetAndDestroy::PushL( aRef ); - } // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------- @@ -116,25 +97,16 @@ void CFindUtilChineseECE::ConstructL(CPcsAlgorithm2* aAlgorithm) { iRepositoryFind = CRepository::NewL(KCRUidAknFep); - // The below code is commented out because current CFindUtilChineseECE is used - // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code - // for the further merging work (merge from FindUtil 5.0) -#if 0 iRepositoryFindAdaptive = CRepository::NewL(KCRUidAvkon); -#endif iWatcher = CFindRepositoryWatcher::NewL(KCRUidAknFep, TCallBack(HandleFindRepositoryCallBack, this), iRepositoryFind); - // The below code is commented out because current CFindUtilChineseECE is used - // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code - // for the further merging work (merge from FindUtil 5.0) -#if 0 iWatcherAdaptive = CFindRepositoryWatcher::NewL(KCRUidAvkon, TCallBack(HandleFindRepositoryCallBack, this), - iRepositoryFindAdaptive); -#endif + iRepositoryFindAdaptive); + iAlgorithm = aAlgorithm; OpenL(); @@ -146,19 +118,11 @@ // CFindUtilChineseECE::CFindUtilChineseECE() : iLanguage(ELangTest), -iSupportPRCChinese(EFalse), -iCurInputMode(KSysInputMode) -// The below code is commented out because current CFindUtilChineseECE is used -// on 3.2.3 which is not supported adaptive search. It will be easy to keep these code -// for the further merging work (merge from FindUtil 5.0) -#if 0 -iSearchMethodPRC(EAdptSearchPinyin), -iSearchMethodTaiWan(EAdptSearchZhuyin), -iSearchMethodHongKong(EAdptSearchStroke), +iCurInputMode(KSysInputMode), +iSearchMethod(EAdptSearchPinyin), iSearchMethodAdaptive(EFalse) -#endif - { - } + { + } // --------------------------------------------------------- // Destructor @@ -168,15 +132,9 @@ { delete iPtiEngine; delete iWatcher; - delete iPtiEnginePrc; delete iRepositoryFind; - // The below code is commented out because current CFindUtilChineseECE is used - // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code - // for the further merging work (merge from FindUtil 5.0) -#if 0 delete iWatcherAdaptive; delete iRepositoryFindAdaptive; -#endif } // --------------------------------------------------------- @@ -188,12 +146,36 @@ if (!iPtiEngine) { iPtiEngine = CPtiEngine::NewL(); - iSupportPRCChinese = IsSupportLanguage(ELangPrcChinese); } if (aLanguage != iLanguage) { - iLanguage = aLanguage; + // We only support Chinese languages. If input language is changed + // to non-Chinese, then first available Chinese language is used + // instead. + if ( aLanguage == ELangPrcChinese || + aLanguage == ELangTaiwanChinese || + aLanguage == ELangHongKongChinese ) + { + iLanguage = aLanguage; + } + else if ( IsSupportLanguage(ELangPrcChinese) ) + { + iLanguage = ELangPrcChinese; + } + else if ( IsSupportLanguage(ELangTaiwanChinese) ) + { + iLanguage = ELangTaiwanChinese; + } + else if ( IsSupportLanguage(ELangHongKongChinese) ) + { + iLanguage = ELangHongKongChinese; + } + else + { + iLanguage = aLanguage; + } + iPtiEngine->ActivateLanguageL(iLanguage); iPtiEngine->EnableToneMarks(EFalse); } @@ -217,6 +199,10 @@ // TBool CFindUtilChineseECE::DoTranslationL(TInt16 aHZUnicode, RPointerArray& aSpellList) { + // Always translate according the adaptive search method setting + return T9ChineseTranslationAdaptiveL(aHZUnicode, aSpellList); + +#if 0 // The below code is commented out because current CFindUtilChineseECE is used // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code // for the further merging work (merge from FindUtil 5.0) @@ -264,13 +250,14 @@ #endif return ETrue; +#endif } // --------------------------------------------------------- // Find pane text is including stroke symbol // --------------------------------------------------------- // -TInt CFindUtilChineseECE::IsStrokeSymbol(const TInt aFindWord) +TInt CFindUtilChineseECE::IsStrokeSymbol(const TUint16 aFindWord) { TInt strokeValue = 0; @@ -298,24 +285,7 @@ return strokeValue; } -TInt CFindUtilChineseECE::CategoryOfLang(TLanguage aLanguage) - { - TInt ret = 0; - if (iLanguage == ELangPrcChinese || ( aLanguage == ELangEnglish && iSupportPRCChinese )) - { - ret = 1; - } - else if (aLanguage == ELangTaiwanChinese) - { - ret = 2; - } - else if (aLanguage == ELangHongKongChinese) - { - ret = 3; - } - return ret; - } - +#if 0 // --------------------------------------------------------- // Do translate for Chinese word // --------------------------------------------------------- @@ -323,7 +293,6 @@ TBool CFindUtilChineseECE::T9ChineseTranslationL(TInt16 aHZUnicode, RPointerArray& aSpellList) { TBuf wordInterpretationBuf; - TBuf numInterpretationBuf; if (iLanguage == ELangPrcChinese) { @@ -389,11 +358,8 @@ return ETrue; } +#endif -// The below code is commented out because current CFindUtilChineseECE is used -// on 3.2.3 which is not supported adaptive search. It will be easy to keep these code -// for the further merging work (merge from FindUtil 5.0) -#if 0 // --------------------------------------------------------- // Do translate for Chinese word // --------------------------------------------------------- @@ -403,121 +369,59 @@ { TBuf wordInterpretationBuf; - if ( iLanguage == ELangPrcChinese ) + switch(iSearchMethod) { - if(iSearchMethodPRC == EAdptSearchPinyin) - { - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) - != KErrNone) - { - return EFalse; - } - } - else if(iSearchMethodPRC == EAdptSearchStroke) - { - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) + case EAdptSearchPinyin: + if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) != KErrNone) { return EFalse; - } - } - else - { - return EFalse; - } - - } - else if ( iLanguage == ELangTaiwanChinese ) - { - if(iSearchMethodTaiWan == EAdptSearchZhuyin) - { - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiZhuyin) + } + break; + case EAdptSearchStroke: + if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) != KErrNone) { return EFalse; - } - } - else if(iSearchMethodTaiWan == EAdptSearchStroke) - { - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) + } + break; + case EAdptSearchZhuyin: + if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiZhuyin) != KErrNone) { return EFalse; - } - } - else - { - return EFalse; - } + } + break; + case EAdptSearchNormalCangjie: + if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) + != KErrNone) + { + return EFalse; + } + break; + case EAdptSearchEasyCangjie: + if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) + != KErrNone) + { + return EFalse; + } + break; + case EAdptSearchAdvCangjie: + if ((iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) != KErrNone) + &&(iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) != KErrNone)) + { + return EFalse; + } + break; + default: + return EFalse; } - else if ( iLanguage == ELangHongKongChinese ) - { - switch(iSearchMethodHongKong) - { - case EAdptSearchNormalCangjie: - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) - != KErrNone) - { - return EFalse; - } - break; - case EAdptSearchEasyCangjie: - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) - != KErrNone) - { - return EFalse; - } - break; - case EAdptSearchAdvCangjie: - if ((iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie) != KErrNone) - &&(iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiEasyCangjie) != KErrNone)) - { - return EFalse; - } - break; - case EAdptSearchStroke: - if (iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiStrokes) - != KErrNone) - { - return EFalse; - } - break; - default: - return EFalse; - } - } - else if ( iLanguage == ELangEnglish ) - { - if (!iSupportPRCChinese) - { - return EFalse; - } - - TInt err = KErrNone; - if (!iPtiEnginePrc) - { - iPtiEnginePrc = CPtiEngine::NewL(EFalse); - TRAP(err, iPtiEnginePrc->ActivateLanguageL(ELangPrcChinese)); - } - - if (err == KErrNone) - { - if (iPtiEnginePrc->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiPinyin) - != KErrNone) - - return EFalse; - } - } - else - { - return EFalse; - } TInt len = wordInterpretationBuf.Length(); TInt start = 0; - if( iSearchMethodHongKong != EAdptSearchAdvCangjie ) + if( iSearchMethod != EAdptSearchAdvCangjie ) { for (TInt i =0; i < len; i++) { @@ -528,7 +432,7 @@ } } - aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); } //Could look advanced cangjie as normal and easy cangjie else @@ -564,8 +468,7 @@ } return ETrue; - } -#endif + } // --------------------------------------------------------- // Find pane text is including separator @@ -583,75 +486,71 @@ void CFindUtilChineseECE::OpenL() { TInt inputLanguage = 0; - //TInt searchMode =0; + TInt searchMode = 0; if (iRepositoryFind != NULL) { iRepositoryFind->Get(KAknFepInputTxtLang, inputLanguage); } + // The following sets iLangueage to inputLanguage if inputLanguage + // is Chinese. If inputLanguage is non-Chinese, iLanguage will be + // set to first available Chinese language. OpenT9InterfaceL((TLanguage) inputLanguage); - // The below code is commented out because current CFindUtilChineseECE is used - // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code - // for the further merging work (merge from FindUtil 5.0) -#if 0 if (iRepositoryFindAdaptive != NULL) { iRepositoryFindAdaptive->Get(KAknAvkonAdaptiveSearchEnabled, iSearchMethodAdaptive); } - if( inputLanguage == ELangPrcChinese) + if (iLanguage == ELangPrcChinese) { - iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC , searchMode); - if(searchMode ==0) + iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC , searchMode); + if (searchMode == 0) { - iSearchMethodPRC = EAdptSearchPinyin; + iSearchMethod = EAdptSearchPinyin; } - else if(searchMode ==1) + else if (searchMode == 1) { - iSearchMethodPRC = EAdptSearchStroke; + iSearchMethod = EAdptSearchStroke; } } - else if(inputLanguage == ELangTaiwanChinese) + else if (iLanguage == ELangTaiwanChinese) { iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseTW , searchMode); - if(searchMode ==0) + if (searchMode == 0) { - iSearchMethodTaiWan = EAdptSearchZhuyin; + iSearchMethod = EAdptSearchZhuyin; } - else if(searchMode ==1) + else if (searchMode == 1) { - iSearchMethodTaiWan = EAdptSearchStroke; - } + iSearchMethod = EAdptSearchStroke; + } } - else if(inputLanguage == ELangHongKongChinese) + else if (iLanguage == ELangHongKongChinese) { iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseHongkong , searchMode); - if(searchMode ==1) - { + if (searchMode == 1) + { iRepositoryFind->Get(KAknFepCangJieMode , searchMode); switch (searchMode) { case 0: - iSearchMethodHongKong = EAdptSearchNormalCangjie; + iSearchMethod = EAdptSearchNormalCangjie; break; case 1: - iSearchMethodHongKong = EAdptSearchEasyCangjie; + iSearchMethod = EAdptSearchEasyCangjie; break; case 2: - iSearchMethodHongKong = EAdptSearchAdvCangjie; + iSearchMethod = EAdptSearchAdvCangjie; break; } - } - else if(searchMode ==0) + else if (searchMode == 0) { - iSearchMethodHongKong = EAdptSearchStroke; + iSearchMethod = EAdptSearchStroke; } - } -#endif } // --------------------------------------------------------- @@ -682,7 +581,7 @@ TBool ret = EFalse; // Check Chinese word in find pane - TBool chineseWord = IsChineseWord(aWord); + TBool chineseWord = IsChineseWordIncluded(aWord); if (chineseWord) { @@ -851,8 +750,25 @@ // TBool CFindUtilChineseECE::MatchRefineL(const TDesC& aItemString, CPsQuery& aPsQuery) { + RArray ignore1; + CleanupClosePushL( ignore1 ); + RArray ignore2; + CleanupClosePushL( ignore2 ); + + TBool match = MatchRefineL( aItemString, aPsQuery, ignore1, ignore2, EFalse ); + + CleanupStack::PopAndDestroy( &ignore2 ); + CleanupStack::PopAndDestroy( &ignore1 ); + + return match; + } + +TBool CFindUtilChineseECE::MatchRefineL(const TDesC& aItemString, CPsQuery& aPsQuery, + RArray& aMatchPos, RArray& aMatchLength, TBool aHighLight ) + { TBuf tempBuf; TBuf itemString; + TBool haschineseword = EFalse; itemString.Zero(); if ( KMaxWordLength > aItemString.Length() ) @@ -870,12 +786,10 @@ if(itemString[0]== KLeftToRightFlag || itemString[0]== KRightToLeftFlag) { itemString.Delete(0,1); - itemString.Delete((itemString.Length()-1),1); + itemString.Delete((itemString.Length()-1),1); } } - TBool haschineseword = EFalse; - // Check function parameter if (aPsQuery.Count() == 0) { @@ -888,8 +802,8 @@ } TBool ret = EFalse; - CPsQuery* query = CPsQuery::NewL(); + CleanupStack::PushL( query ); GetPartOfQueryL(aPsQuery, 0, aPsQuery.Count()-1, *query); RemoveSeparatorL(*query); TPtrC queryStrPtr = query->QueryAsStringLC(); @@ -912,78 +826,63 @@ { iCurInputMode = KSysInputMode; } - - // Check Chinese word in find pane - if (IsChineseWord(tempBuf)) + + TBool inputMethodStroke = EFalse; + if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) + { + inputMethodStroke = ETrue; + } + + // Check if any Chinese word in find pane + if ( IsChineseWordIncluded(tempBuf) ) { haschineseword = ETrue; ret = IncludeString(aItemString, tempBuf); - - if (ret) + + if( IsAllChineseWord( tempBuf )) { + CleanupStack::PopAndDestroy( query ); return ret; } - /* else - { - // if Stroke Symbol in HongKong - TBool strokeSymHK = (IsStrokeSymbolInString(tempBuf)) && - (iLanguage == ELangHongKongChinese) && - iCurInputMode == 0x0020; - - if (!strokeSymHK) - { - return ret; - } - }*/ } - //Find if search string has chinese word. - //Compare with item string if find chinese word in item string then delete it from search and item string. - //if not then return EFalse. - TBool InputMethodStroke = EFalse; - if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) - { - InputMethodStroke = ETrue; - } - + + // There are two steps to do when searchstring includes Chinese character + // + // step 1: check whether itemstring includes the chinese charactor in the searchstring + // If not, return EFalse. Otherwise, go to step2 + // + // step2: If itemstring includes the chinese charactor in the searchstring, translate + // the Chinese character in the searchstring to spellList and reconstruct the query. if (haschineseword) { TInt ii=0; - TBool leftDifferentChinese = EFalse; //Fixed for ESSG-7PJ6GF, flag the different Chinese character at the left of aSearchText. + + // Step 1: + // E.g: itemstring = "0x4E00,0x4E8C,0x4E09,0x56DB,0x4E94" + // (Unicode of Chinese number "1 2 3 4 5") + // searchstring1 = "0x4E00,x,y,z,0x4E09" + // searchstring2 = "0x4E8C,0x4E00" + // searchstring3 = "0x4E00,0x4E5D" + // In this case, searchstring2 and searchstring3 will return EFalse, + // only searchstring1 will be translated to spellList in step 2 while (ii< tempBuf.Length()) { - if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke - ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii])))) + TInt lastFindCursor = -1; + if( (TUint16)tempBuf[ii] <= KMaxUnicodeHz + && (TUint16)tempBuf[ii]>= KMinUnicodeHz + && ( !inputMethodStroke ||(inputMethodStroke && + !IsStrokeSymbol(tempBuf[ii])) ) ) { TInt Findcursor = itemString.Locate(tempBuf[ii]); - if (Findcursor != KErrNotFound) + if( KErrNotFound == Findcursor || Findcursor < lastFindCursor ) { - if ((Findcursor == itemString.Length()-1)&& (ii - ==tempBuf.Length()-1)) - { - //Start:Fixed for ESSG-7PJ6GF - if ( leftDifferentChinese || IsChineseWord( - itemString.Left( Findcursor ) ) ) - { - //if the different Chinese character at the left or middle, return false. - return EFalse; - } - //End:Fixed for ESSG-7PJ6GF - return ETrue; - } - itemString.Delete(0, Findcursor+1); - tempBuf.Delete(0, ii+1); - ii=0; + CleanupStack::PopAndDestroy( query ); + return EFalse; } else { - //Start:Fixed for ESSG-7PJ6GF - if ( IsChineseWord( tempBuf.Left( ii + 1 ) ) ) - { - //flag the different Chinese character at the left. - leftDifferentChinese = ETrue; - } - //End:Fixed for ESSG-7PJ6GF + lastFindCursor = Findcursor; ii++; } } @@ -992,9 +891,70 @@ ii++; } } + + ii = 0; + // Counter of queryItem + TInt queryItemCount = 0; + + //Step 2: + // Translating searchstring to spellList and reconstruct query + while ( ii< tempBuf.Length() ) + { + // If it is a valid chinese character + if ( (TUint16)tempBuf[ii] <= KMaxUnicodeHz + && (TUint16)tempBuf[ii]>= KMinUnicodeHz + && ( !inputMethodStroke ||(inputMethodStroke && + !IsStrokeSymbol(tempBuf[ii])) ) ) + { + RPointerArray spellList; + + // If successfully translating the chinese character to spellList( Pinyin,Zhuyin or stroke ) + // then reconstruct the query, replace the Chinese character with its spellList in the query. + // Otherwise, just increase the counter of queryItem. + if( DoTranslationL(TInt16(tempBuf[ii]), spellList) ) + { + // Replace the queryItem by the translated spelling + CPsQueryItem& tempItem = query->GetItemAtL(queryItemCount); + const TKeyboardModes tempMode = tempItem.Mode(); + + // Remove the Chinese character queryItem + query->Remove(queryItemCount); + + // Reconstruct the query, replace Chinese character with its spellList + for(TInt cnt = 0; cnt < spellList[0]->Length(); cnt++) + { + // Add a new query item to query + CPsQueryItem* newItem = CPsQueryItem::NewL(); + CleanupStack::PushL(newItem); + newItem->SetCharacter( (*spellList[0])[cnt] ); + newItem->SetMode(tempMode); + + query->InsertL(*newItem, queryItemCount + cnt ); + CleanupStack::Pop(newItem); + } + + queryItemCount += spellList[0]->Length(); + } + else + { + queryItemCount++; + } + + ii++; + spellList.ResetAndDestroy(); + spellList.Close(); + + } + //if not, just pass it by + else + { + ii++; + queryItemCount++; + } + } } - + // Array for item string RPointerArray stringInfoArr; // Split item string @@ -1002,13 +962,13 @@ if (stringInfoArr.Count() > 0) { - ret = MatchSegmentL(stringInfoArr, *query); + ret = MatchSegmentL(stringInfoArr, *query, aMatchPos, aMatchLength, aHighLight); } stringInfoArr.ResetAndDestroy(); stringInfoArr.Close(); - delete query; + CleanupStack::PopAndDestroy( query ); return ret; } @@ -1018,7 +978,7 @@ // --------------------------------------------------------- // void CFindUtilChineseECE::SplitItemStringL(RPointerArray& aStringInfoArr, - const TDesC &aItemString) + const TDesC& aItemString) { TBuf tempBuf; TBuf englishBuf; @@ -1029,8 +989,7 @@ chineseBuf.Zero(); TInt index = 0; - TUint32 temp = 0; - TInt32 distance = 0; + TBool isChinese = EFalse; const TInt strLength = aItemString.Length(); for (; index < strLength; index++) @@ -1039,35 +998,35 @@ { // Check Chinese and English Buf. If it is not empty, // add buf to Array - InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); - InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); + InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); + InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); continue; } - temp = aItemString[index]; - distance = (TInt32)(temp - KMinUnicodeHz); - - if (distance < 0)// English word + isChinese = ((TUint16)aItemString[index] >= KMinUnicodeHz && + (TUint16)aItemString[index] <= KMaxUnicodeHz); + + if ( !isChinese )// English word { // Chinese word is end and add to array - InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); + InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); // Add English word to array - englishBuf.Append((TChar) aItemString[index]); + englishBuf.Append(aItemString[index]); } else // Chinese word { // English word is end and add to array - InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); + InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); // Add Chinese word to array - chineseBuf.Append((TChar) aItemString[index]); + chineseBuf.Append(aItemString[index]); } } // Finish loop check buffer is empty - InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue); - InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse); + InsertStrInforArrayL(aStringInfoArr, chineseBuf, ETrue, index); + InsertStrInforArrayL(aStringInfoArr, englishBuf, EFalse, index); } // --------------------------------------------------------- @@ -1075,9 +1034,8 @@ // --------------------------------------------------------- // void CFindUtilChineseECE::InsertStrInforArrayL(RPointerArray& aStringInfoArr, - TDes &aSegmentStr, const TBool aChinese) + TDes &aSegmentStr, TBool aChinese, TInt aIndexAfterStr) { - CleanupResetAndDestroyPushL( aStringInfoArr ); if (aSegmentStr.Length() <= 0) { return; @@ -1089,10 +1047,10 @@ strInfo->segmentString.Copy(aSegmentStr); strInfo->segmentString.LowerCase(); strInfo->isChinese = aChinese; + strInfo->segmentPos = aIndexAfterStr - aSegmentStr.Length(); aStringInfoArr.AppendL(strInfo); aSegmentStr.Zero(); - CleanupStack::Pop( &aStringInfoArr ); } // --------------------------------------------------------- @@ -1100,107 +1058,133 @@ // --------------------------------------------------------- // TBool CFindUtilChineseECE::MatchSegmentL(RPointerArray& aStringInfoArr, - CPsQuery& aQuery) + CPsQuery& aQuery, RArray& aMatchPos, RArray& aMatchLength, TBool aHighLight ) { const TInt arrayLength = aStringInfoArr.Count(); const TInt searchStrLength = aQuery.Count(); - TInt searchStrIndex = 0; STRINGINFO* pStringInfo; TInt index = 0; + TBool ret = EFalse; + TBool hasChinese = EFalse; - // First only check English + // First check if there is a full match in non-Chinese in any one segment for (; index < arrayLength; index++) { + pStringInfo = aStringInfoArr[index]; + TPtrC currentSeg( pStringInfo->segmentString ); + TInt matchLen( 0 ); + + // Compare word + if (pStringInfo->isChinese) + { + hasChinese = ETrue; + } + else + { + matchLen = MatchStringL( currentSeg, aQuery ); + } + + // If full match is found + if ( matchLen == searchStrLength ) + { + //Only append postion of non-Chinese character + if( !pStringInfo->isChinese ) + { + aMatchPos.Append( pStringInfo->segmentPos ); + aMatchLength.Append( matchLen ); + } + ret = ETrue; + + // If there is no need to HighLight the matched part, return immediately + // Otherwise, continue to find all the matched positions + if( !aHighLight ) + return ret; + } + } + + // Then search through segments again, this time considering + // also cases where matching part continues over several segments. + // This algorithm is greedy and heuristic and can't necesarily find + // all the matches in the segments after the first one. + TPtrC segCurrent; + TInt searchStrIndextemp = 0; + TInt searchStrIndexMax = 0; + TInt searchStrIndex = 0; + index = 0; + + // Loop through seqments until whole query is matched + for (; index < arrayLength && !ret ; index++) + { // Create an empty CPsQuery CPsQuery* tempQuery = CPsQuery::NewL(); - pStringInfo = aStringInfoArr[index]; - - GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, - *tempQuery ); + CleanupStack::PushL( tempQuery ); - // Compare word - if (!pStringInfo->isChinese) - { - searchStrIndex += MatchString(pStringInfo->segmentString, *tempQuery); - } + GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, *tempQuery ); - delete tempQuery; - tempQuery = NULL; - - if (searchStrIndex >= searchStrLength) - { - return ETrue; - } - } + pStringInfo = aStringInfoArr[index]; + segCurrent.Set( pStringInfo->segmentString ); - TBuf bufcurrent; - TBuf tempbufcurrent; - TInt searchStrIndextemp = 0; - TInt searchStrIndexMax = 0; - // Find Chinese and English - searchStrIndex = 0; - index = 0; - - for (; index < arrayLength; index++) - { - // Create an empty CPsQuery - CPsQuery* tempQuery = CPsQuery::NewL(); - pStringInfo = aStringInfoArr[index]; - - GetPartOfQueryL( aQuery, searchStrIndex, searchStrLength - 1, - *tempQuery ); - searchStrIndexMax = 0; - - bufcurrent = pStringInfo->segmentString; - - for(TInt i =0;i< pStringInfo->segmentString.Length();i++) + if (pStringInfo->isChinese) { - tempbufcurrent = bufcurrent.Mid(i); - if (pStringInfo->isChinese) + // find the longest substring matching the query + searchStrIndexMax = 0; + for (TInt i = 0; i< segCurrent.Length(); i++) { - TInt temp=0; - searchStrIndextemp = MatchChineseStringL(tempbufcurrent, *tempQuery, temp); - if(searchStrIndextemp > searchStrIndexMax) + TPtrC tempSeg( segCurrent.Mid(i) ); + TInt startIdx( KErrNotFound ); + TInt endIdx( KErrNotFound ); + searchStrIndextemp = MatchChineseStringL(tempSeg, *tempQuery, startIdx, endIdx); + if (searchStrIndextemp > searchStrIndexMax) { searchStrIndex -= searchStrIndexMax; searchStrIndexMax = searchStrIndextemp; searchStrIndex += searchStrIndexMax; } + + if (searchStrIndex >= searchStrLength) + { + // found substring which consumes whole query, no need to find any longer + break; + } } - else - { - searchStrIndex += MatchString(pStringInfo->segmentString, *tempQuery); - } - - if (searchStrIndex >= searchStrLength) + } + else // not chinese + { + TInt matchLen = MatchStringL(segCurrent, *tempQuery); + searchStrIndex += matchLen; + if ( matchLen ) { - delete tempQuery; - tempQuery = NULL; - return ETrue; - } - else if(!pStringInfo->isChinese) - { - break; + aMatchPos.Append( pStringInfo->segmentPos ); + aMatchLength.Append( matchLen ); } } - delete tempQuery; - tempQuery = NULL; + if (searchStrIndex >= searchStrLength) + { + ret = ETrue; // also breaks us out from the loop + } + else if ( !pStringInfo->isChinese && !hasChinese ) + { + CleanupStack::PopAndDestroy( tempQuery ); + break; + } + + CleanupStack::PopAndDestroy( tempQuery ); } - return EFalse; + return ret; } // --------------------------------------------------------- // Search Chinese word in input text // --------------------------------------------------------- // -TInt CFindUtilChineseECE::MatchChineseStringL(const TDesC& aSearhTargetString, CPsQuery& aQuery, TInt& aIndex) +TInt CFindUtilChineseECE::MatchChineseStringL(const TDesC& aSearhTargetString, CPsQuery& aQuery, + TInt& aMatchStartIdx, TInt& aMatchEndIdx) { const TInt stringLength = aSearhTargetString.Length(); const TInt searchLength = aQuery.Count(); TInt index = 0; - //TBuf tempBuf; TBuf previousBuf; TInt curMatchCount = 0; TInt preMatchCount = 0; @@ -1208,6 +1192,13 @@ TInt curSearchIndex = 0; TBool bFullMatched = EFalse; TBool bContinue = EFalse; + TBool bPrevReplaced = EFalse; + aMatchStartIdx = KErrNotFound; + aMatchEndIdx = KErrNotFound; + + CPsQuery* tempFullQuery = CPsQuery::NewL(); + CleanupStack::PushL( tempFullQuery ); + GetPartOfQueryL( aQuery, 0, aQuery.Count() - 1, *tempFullQuery ); for (; index < stringLength; index++) { @@ -1226,17 +1217,17 @@ // Get left string CPsQuery* tempQuery = CPsQuery::NewL(); - GetPartOfQueryL( aQuery, curSearchIndex, searchLength - 1, - *tempQuery ); + CleanupStack::PushL( tempQuery ); + GetPartOfQueryL( aQuery, curSearchIndex, searchLength - 1, *tempQuery ); - // Get Matched count and the matched index in list - curMatchCount = MaxMatchInList(spellList, *tempQuery, previousBuf, matchIndex, - bFullMatched, preMatchCount, bContinue); + // Get Matched count and the matched index in list + curMatchCount = MaxMatchInListL(spellList, *tempQuery, previousBuf, matchIndex, + bFullMatched, preMatchCount, bContinue, bPrevReplaced, *tempFullQuery); // There is a string matched in list if (curMatchCount != 0) { - previousBuf.Copy(spellList[matchIndex]->Des()); + previousBuf.Copy(*spellList[matchIndex]); if (curMatchCount == previousBuf.Length()) { @@ -1247,7 +1238,7 @@ bFullMatched = EFalse; } - // If it is repeat match, continue + // If it is repeat match, continue if (!bContinue) { curSearchIndex += curMatchCount; @@ -1258,6 +1249,14 @@ previousBuf.Zero(); curMatchCount = 0; } + + // Store the index of first matched Han character + if ( bPrevReplaced || aMatchStartIdx == KErrNotFound ) + { + aMatchStartIdx = index; + } + // Store the index of last matched Han character + aMatchEndIdx = index; } else { @@ -1269,13 +1268,17 @@ } curSearchIndex = 0; + + // Any earlier partial match is discarded, reset the matching part indices + aMatchStartIdx = KErrNotFound; + aMatchEndIdx = KErrNotFound; } spellList.ResetAndDestroy();//destroy spellList spellList.Close(); preMatchCount = curMatchCount; - delete tempQuery; + CleanupStack::PopAndDestroy( tempQuery ); tempQuery = NULL; // Search to End and return @@ -1284,8 +1287,9 @@ break; } } + CleanupStack::PopAndDestroy( tempFullQuery ); + tempFullQuery = NULL; - aIndex = index; return curSearchIndex; } @@ -1293,11 +1297,11 @@ // Maximal matched count in spelling list // --------------------------------------------------------- // -TInt CFindUtilChineseECE::MaxMatchInList(RPointerArray &spellList, CPsQuery& aQuery, +TInt CFindUtilChineseECE::MaxMatchInListL(RPointerArray &aSpellList, CPsQuery& aQuery, TDesC& aPreviouStr, TInt& aMatchIndex, const TBool aFullMatched, - const TInt aMatchedCount, TBool& aAgain) + const TInt aMatchedCount, TBool& aAgain, TBool& aPrevReplaced, CPsQuery& aFullQuery) { - const TInt itemCount = spellList.Count(); + const TInt itemCount = aSpellList.Count(); TInt matchCount = 0; TBool selfMatch = EFalse; aMatchIndex = 0; @@ -1320,9 +1324,9 @@ repeatCount = 0; loopFlag = EFalse; tempBuf.Zero(); - tempBuf.Copy(spellList[index]->Des()); + tempBuf.Copy( *aSpellList[index] ); - temp = MatchString(tempBuf, aQuery); + temp = MatchStringL(tempBuf, aQuery); if(temp != 0) { selfMatch = ETrue; @@ -1337,11 +1341,11 @@ // Previous word is fully matched if (aFullMatched) { - repeatCount = ReverseMatchString(aPreviouStr, tempBuf); + repeatCount = ReverseMatchStringL(aPreviouStr, tempBuf, aFullQuery ); // Find repeat and remove it, search again if (repeatCount != 0) { - temp = MatchString(tempBuf.Right(tempBuf.Length() - repeatCount), aQuery); + temp = MatchStringL(tempBuf.Right(tempBuf.Length() - repeatCount), aQuery); if (temp == 0) { @@ -1352,14 +1356,14 @@ } else { - repeatCount = MatchString(aPreviouStr, tempBuf); + repeatCount = MatchStringL(aPreviouStr, tempBuf, aFullQuery); // Find repeat and remove it, search again if (repeatCount != 0) { if (aMatchedCount <= repeatCount) { - temp = MatchString(tempBuf.Right(tempBuf.Length() - aMatchedCount), aQuery); + temp = MatchStringL(tempBuf.Right(tempBuf.Length() - aMatchedCount), aQuery); if (temp == 0) { @@ -1371,11 +1375,11 @@ if (temp == 0) { - repeatCount = ReverseMatchString(aPreviouStr.Left(aMatchedCount), tempBuf); + repeatCount = ReverseMatchStringL(aPreviouStr.Left(aMatchedCount), tempBuf, aFullQuery); if (repeatCount != 0) { - temp = MatchString(tempBuf.Right(tempBuf.Length() - repeatCount), aQuery); + temp = MatchStringL(tempBuf.Right(tempBuf.Length() - repeatCount), aQuery); if (temp == 0) { @@ -1414,16 +1418,20 @@ aMatchIndex = index; aAgain = loopFlag; } - if(matchCount == aQuery.Count() && selfMatch) + if (matchCount == aQuery.Count() && selfMatch) { break; } } + + // Was the previous match replaced with a longer match from this spell list + aPrevReplaced = ( matchCount && repeatCount ); + return matchCount; } // --------------------------------------------------------- -// Search the taxt is include the input text +// Search the text is include the input text // --------------------------------------------------------- // TBool CFindUtilChineseECE::IncludeString(const TDesC& aFirst, const TDesC& aSecond) @@ -1455,29 +1463,22 @@ // Search text in other text // --------------------------------------------------------- // -TInt CFindUtilChineseECE::MatchString(const TDesC& aFirst, const TDesC& aSecond) +TInt CFindUtilChineseECE::MatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery) { const TInt secondStrLength = aSecond.Length(); const TInt firstStrLength = aFirst.Length(); - const TInt compareCount = firstStrLength > secondStrLength ? secondStrLength - : firstStrLength; + const TInt compareCount = Min( firstStrLength, secondStrLength ); TInt index = 0; - - TBuf tempStr; - // translate search target string into numeric string before match - if (iAlgorithm) - { - iAlgorithm->Converter( aFirst, tempStr ); - } - else - { - tempStr.Copy(aFirst); - } + TBuf firstNumInterpretationBuf; + TBuf secondNumInterpretationBuf; + + iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aFirst, firstNumInterpretationBuf); + iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aSecond, secondNumInterpretationBuf); for (; index < compareCount; index++) { - if (tempStr.Left(index + 1).FindC(aSecond.Left(index + 1)) == KErrNotFound) + if (firstNumInterpretationBuf.Left(index + 1).FindC(secondNumInterpretationBuf.Left(index + 1)) == KErrNotFound) { break; } @@ -1485,32 +1486,32 @@ // Match count return index; } + // --------------------------------------------------------- // Search CPsQuery in aSearhTargetStr // --------------------------------------------------------- // -TInt CFindUtilChineseECE::MatchString(const TDesC& aSearhTargetStr, CPsQuery& aQuery) +TInt CFindUtilChineseECE::MatchStringL(const TDesC& aSearhTargetStr, CPsQuery& aQuery) { const TInt secondStrLength = aQuery.Count(); const TInt firstStrLength = aSearhTargetStr.Length(); TBuf numInterpretationBuf; + TBuf queryStr; - const TInt compareCount = firstStrLength > secondStrLength ? secondStrLength - : firstStrLength; + const TInt compareCount = Min( firstStrLength, secondStrLength ); + TInt index = 0; - ConvertdDataToKeyBoardModeL(aQuery, aSearhTargetStr, numInterpretationBuf); + iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aQuery, aSearhTargetStr, numInterpretationBuf); + iAlgorithm->GetKeyMap()->GetMixedKeyStringForQueryL(aQuery, queryStr); - TPtrC queryStr = aQuery.QueryAsStringLC(); for (; index < compareCount; index++) { - if (numInterpretationBuf.Left(index + 1).FindC(queryStr.Left(index + 1)) == KErrNotFound) { break; } } - CleanupStack::PopAndDestroy(); // Match count return index; @@ -1520,32 +1521,22 @@ // Search text by reverse // --------------------------------------------------------- // -TInt CFindUtilChineseECE::ReverseMatchString(const TDesC& aFirst, const TDesC& aSecond) +TInt CFindUtilChineseECE::ReverseMatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery) { const TInt secondStrLength = aSecond.Length(); const TInt firstStrLength = aFirst.Length(); TInt compareCount = firstStrLength > secondStrLength ? secondStrLength : firstStrLength; TInt index = 0; TInt matchCount = 0; - + TBuf firstNumInterpretationBuf; + TBuf secondNumInterpretationBuf; + + iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aFirst, firstNumInterpretationBuf); + iAlgorithm->GetKeyMap()->GetMixedKeyStringForDataL(aFullQuery, aSecond, secondNumInterpretationBuf); + for (; index < compareCount; index++) { - TBuf firstConvStr; - TBuf secondConvStr; - - // translate compared target string into numeric string before match - if ( iAlgorithm ) - { - iAlgorithm->Converter( aFirst, firstConvStr ); - iAlgorithm->Converter( aSecond, secondConvStr ); - } - else - { - firstConvStr.Copy( aFirst ); - secondConvStr.Copy( aSecond ); - } - - if( firstConvStr.Right( index + 1 ).FindC( secondConvStr.Left( index + 1 ) ) != KErrNotFound ) + if( firstNumInterpretationBuf.Right( index + 1 ).FindC( secondNumInterpretationBuf.Left( index + 1 ) ) != KErrNotFound ) { matchCount = index + 1; } @@ -1567,14 +1558,16 @@ // Find pane text is including Chinese word // --------------------------------------------------------- // -TBool CFindUtilChineseECE::IsChineseWord(const TDesC& aWord) +TBool CFindUtilChineseECE::IsChineseWordIncluded(const TDesC& aWord) { TBool IsChineseSearchStr = EFalse; const TInt len = aWord.Length(); for (TInt ii = 0; ii < len; ii++) { - if ((TInt) aWord[ii] >= KMinUnicodeHz) + + if ( ((TUint16) aWord[ii] >= KMinUnicodeHz) && + ((TUint16) aWord[ii] <= KMaxUnicodeHz) ) { IsChineseSearchStr = ETrue; break; @@ -1594,7 +1587,7 @@ for (TInt index = 0; index < len; index++) { - if (IsStrokeSymbol(TInt(aWord[index])) != 0) + if (IsStrokeSymbol(TUint16(aWord[index])) != 0) { return ETrue; } @@ -1602,6 +1595,33 @@ return EFalse; } +// -------------------------------------------------------- +// Find pane text is all Chinese word(s) +// -------------------------------------------------------- +// +TBool CFindUtilChineseECE::IsAllChineseWord(const TDesC& aWord) + { + TBool isChineseWord = ETrue; + const TInt len = aWord.Length(); + + TBool InputMethodStroke = EFalse; + if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020) + { + InputMethodStroke = ETrue; + } + + for( TInt i = 0; i < len; i++ ) + { + if( (( TUint16 )aWord[i] > KMaxUnicodeHz ) || (( TUint16 )aWord[i] < KMinUnicodeHz ) + || ( InputMethodStroke && IsStrokeSymbol(aWord[i]) ) ) + { + isChineseWord = EFalse; + break; + } + } + return isChineseWord; + } + // --------------------------------------------------------- // Find pane text is including zhuyin symbol // --------------------------------------------------------- @@ -1643,108 +1663,37 @@ TInt CFindUtilChineseECE::HandleFindRepositoryCallBack(TAny* aPtr) { TInt ret = KErrNone; - CFindUtilChineseECE *self = static_cast (aPtr); - TInt searchMode = 0; + CFindUtilChineseECE* self = static_cast (aPtr); - if (self->iWatcher->ChangedKey() == KAknFepInputTxtLang) + // Get changed key either from language repository (AknFepRepository) + // or from adaptive repository (AvkonRepository). + TUint32 changedKey = self->iWatcher->ChangedKey(); + if ( changedKey == NCentralRepositoryConstants::KInvalidNotificationId ) { - TInt inputLanguage = 0; - self->iRepositoryFind->Get(KAknFepInputTxtLang, inputLanguage); + changedKey = self->iWatcherAdaptive->ChangedKey(); + } + - TInt prevCategory = self->CategoryOfLang(self->iLanguage); - TRAP(ret, self->OpenT9InterfaceL(TLanguage(inputLanguage))); + // Update the search method if input language or any search method variable + // changed + if ( changedKey == KAknFepInputTxtLang || + changedKey == KAknAdaptiveSearchChinesePRC || + changedKey == KAknAdaptiveSearchChineseTW || + changedKey == KAknAdaptiveSearchChineseHongkong || + changedKey == KAknFepCangJieMode || + changedKey == KAknAvkonAdaptiveSearchEnabled ) + { + TChineseSearchMethod prevSearchMethods = self->iSearchMethod; - TInt category = self->CategoryOfLang(TLanguage(inputLanguage)); - if (prevCategory != category && category != 0) + TRAP( ret, self->OpenL() ); + + // Reconstruct cache if search method got changed + if ( ret == KErrNone && prevSearchMethods != self->iSearchMethod ) { TRAP(ret, self->iAlgorithm->ReconstructCacheDataL()); } } - - // The below code is commented out because current CFindUtilChineseECE is used - // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code - // for the further merging work (merge from FindUtil 5.0) -#if 0 - if(self->iWatcherAdaptive->ChangedKey() == KAknAvkonAdaptiveSearchEnabled) - { - self->iRepositoryFindAdaptive->Get(KAknAvkonAdaptiveSearchEnabled, self->iSearchMethodAdaptive); - } - - if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChinesePRC) - { - self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChinesePRC, searchMode); - - if(searchMode ==0) - { - self->iSearchMethodPRC = EAdptSearchPinyin; - } - else if(searchMode ==1) - { - self->iSearchMethodPRC = EAdptSearchStroke; - } - } - - if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChineseTW ) - { - self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseTW , searchMode); - - if(searchMode ==0) - { - self->iSearchMethodTaiWan = EAdptSearchZhuyin; - } - else if(searchMode ==1) - { - self->iSearchMethodTaiWan = EAdptSearchStroke; - } - } - - if (self->iWatcherAdaptive->ChangedKey() == KAknAdaptiveSearchChineseHongkong ) - { - self->iRepositoryFindAdaptive->Get(KAknAdaptiveSearchChineseHongkong , searchMode); - - if(searchMode ==1) - { - self->iRepositoryFind->Get(KAknFepCangJieMode , searchMode); - - switch (searchMode) - { - case 0: - self->iSearchMethodHongKong = EAdptSearchNormalCangjie; - break; - case 1: - self->iSearchMethodHongKong = EAdptSearchEasyCangjie; - break; - case 2: - self->iSearchMethodHongKong = EAdptSearchAdvCangjie; - break; - } - - } - else if(searchMode ==0) - { - self->iSearchMethodHongKong = EAdptSearchStroke; - } - } - - if (self->iWatcher->ChangedKey() == KAknFepCangJieMode ) - { - self->iRepositoryFind->Get(KAknFepCangJieMode , searchMode); - - switch (searchMode) - { - case 0: - self->iSearchMethodHongKong = EAdptSearchNormalCangjie; - break; - case 1: - self->iSearchMethodHongKong = EAdptSearchEasyCangjie; - break; - case 2: - self->iSearchMethodHongKong = EAdptSearchAdvCangjie; - break; - } - - } -#endif + return ret; } @@ -1777,11 +1726,6 @@ } } -void CFindUtilChineseECE::SetKeyboardMode(TInt aMode) - { - iKeyboardMode = aMode; - } - // The below code is commented out because current CFindUtilChineseECE is used // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code // for the further merging work (merge from FindUtil 5.0) @@ -1798,7 +1742,7 @@ { aNextChars = aNextChars->ReAllocL( aNextChars->Des().MaxLength()+10 ); } - aNextChars->Des().Append(aCh); + aNextChars->Des().Append(aCh); } } @@ -1990,7 +1934,7 @@ // Compare word if (!pStringInfo->isChinese) { - searchStrIndex += MatchString(pStringInfo->segmentString, + searchStrIndex += MatchStringL(pStringInfo->segmentString, transSearchBuf); } @@ -2070,7 +2014,7 @@ } tempSpellList.ResetAndDestroy(); - if(ReverseMatchString(aCurrentBuf,temp)>0) + if(ReverseMatchStringL(aCurrentBuf,temp)>0) { if (pStringInfo->isChinese) { @@ -2320,7 +2264,7 @@ //Find if search string has chinese word. //Compare with item string if find chinese word in item string then delete it from search and item string. - if(IsChineseWord(tempBuf)) + if(IsChineseWordIncluded(tempBuf)) { if(TrimChineseCharacterL(itemString,tempBuf,aNextChars)) { @@ -2405,7 +2349,7 @@ } else {//english words and chinese words don't coexist in same segment - matchLength = MatchString(bufcurrent, transSearchBuf); + matchLength = MatchStringL(bufcurrent, transSearchBuf); searchStrIndex +=matchLength; if (searchStrIndex >= searchStrLength) { @@ -2554,58 +2498,6 @@ } #endif -// ---------------------------------------------------------------------------- -// CFindUtilChineseECE::ConvertdDataToKeyBoardModeL -// Converts the input data to the key board mode specified by the query -// ---------------------------------------------------------------------------- -void CFindUtilChineseECE::ConvertdDataToKeyBoardModeL(CPsQuery& aQuery, - const TDesC& aSearchTargetStr, - TBuf& aOutputNumInterpretationStr) - { - if (iKeyboardMode == EItut) - { - iAlgorithm->GetKeyMap()->GetNumericKeyString(aSearchTargetStr, aOutputNumInterpretationStr); - } - else if (iKeyboardMode == EQwerty) - { - aOutputNumInterpretationStr = aSearchTargetStr; - aOutputNumInterpretationStr.LowerCase(); - } - else - { - - TInt len = -1; - TBuf outBuf; - - iAlgorithm->GetKeyMap()->GetNumericKeyString(aSearchTargetStr, outBuf); - - // Always loop thru the lowest length - if (aSearchTargetStr.Length() > aQuery.Count() ) - { - len = aQuery.Count(); - } - else - { - len = aSearchTargetStr.Length(); - } - - // Interprete search target str according to the query char mode - for (TInt i = 0; i < len; i++) - { - if (aQuery.GetItemAtL(i).Mode() == EItut) - { - aOutputNumInterpretationStr.Append(outBuf[i]); - } - else - { - aOutputNumInterpretationStr.Append(aSearchTargetStr[i]); - } - } - - aOutputNumInterpretationStr.LowerCase(); - } - } - void CFindUtilChineseECE::GetPartOfQueryL(CPsQuery& aSrcQuery, TInt aStartIndex, TInt aEndIndex, CPsQuery& aDestQuery) { @@ -2624,7 +2516,6 @@ aDestQuery.AppendL(*newItem); } - } else { @@ -2651,6 +2542,7 @@ // ajust index after remove index--; } + break; default: continue; } // switch