diff -r fcdfafb36fe7 -r aecbbf00d063 uiutils/Findutil/src/FindUtilChinese.cpp --- a/uiutils/Findutil/src/FindUtilChinese.cpp Thu Aug 19 10:11:06 2010 +0300 +++ b/uiutils/Findutil/src/FindUtilChinese.cpp Tue Aug 31 15:28:30 2010 +0300 @@ -108,13 +108,7 @@ iWatcherAdaptive = CFindRepositoryWatcher::NewL(KCRUidAvkon, TCallBack(HandleFindRepositoryCallBack, this), - iRepositoryFindAdaptive); - iEikEnv = CEikonEnv::Static(); - if (iEikEnv) - { - TUid appUid(iEikEnv->EikAppUi()->Application()->AppDllUid()); - iIsPhoneBook = (appUid== KUidPhoneBook || appUid == KUidPhoneBookServer); - } + iRepositoryFindAdaptive); } // --------------------------------------------------------- @@ -128,9 +122,7 @@ iSearchMethodPRC(EAdptSearchPinyin), iSearchMethodTaiWan(EAdptSearchZhuyin), iSearchMethodHongKong(EAdptSearchStroke), - iSearchMethodAdaptive(EFalse), - iEikEnv(NULL), - iIsPhoneBook(EFalse) + iSearchMethodAdaptive(EFalse) { } @@ -187,9 +179,10 @@ TBool CFindUtilChinese::DoTranslationL(TInt16 aHZUnicode, RPointerArray& aSpellList) { - if(iEikEnv) + if(CEikonEnv::Static()) { - if (iSearchMethodAdaptive && iIsPhoneBook) + if (iSearchMethodAdaptive &&(CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidPhoneBook || + CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidPhoneBookServer )) { if (!T9ChineseTranslationAdaptiveL(aHZUnicode, aSpellList)) { @@ -325,17 +318,14 @@ { if (wordInterpretationBuf[i] == KSeperator) { - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); start = i + 1; } } + + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); - + return ETrue; } @@ -468,16 +458,12 @@ { if (wordInterpretationBuf[i] == KSeperator) { - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); start = i + 1; } } - - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); } //Could look advanced cangjie as normal and easy cangjie else @@ -489,17 +475,14 @@ { if (wordInterpretationBuf[i] == KSeperator) { - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); start = i + 1; } } - - HBufC16* tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); - + + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); + + iPtiEngine->GetSpelling(aHZUnicode, wordInterpretationBuf, EPtiCangJie); len = wordInterpretationBuf.Length(); start = 0; @@ -507,16 +490,12 @@ { if (wordInterpretationBuf[i] == KSeperator) { - tmpStr = (wordInterpretationBuf.MidTPtr(start, i-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, i-start)).Alloc()); start = i + 1; } } - - tmpStr = (wordInterpretationBuf.MidTPtr(start, len-start)).AllocLC(); - aSpellList.AppendL(tmpStr); - CleanupStack::Pop(tmpStr); + + aSpellList.Append((wordInterpretationBuf.MidTPtr(start, len-start)).Alloc()); } return ETrue; @@ -875,7 +854,7 @@ haschineseword = ETrue; ret = IncludeString(aItemString, tempBuf); - if (ret) + if (ret || ChineseWord( tempBuf )) { return ret; } @@ -905,50 +884,45 @@ if (haschineseword) { TInt ii=0; - TBool leftDifferentChinese = EFalse; - //this is used for fixing for the issue of search string including Chinese characters + TBuf tmpBuf; + tmpBuf.Zero(); + + ////translate the whole searchstring to spelllist while (ii< tempBuf.Length()) { + + //if it is a valid chinese character if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii])))) { - TInt Findcursor = itemString.Locate(tempBuf[ii]); - if (Findcursor != KErrNotFound) - { - if ((Findcursor == itemString.Length()-1)&& (ii - ==tempBuf.Length()-1)) - { - - if ( leftDifferentChinese || IsChineseWord( - itemString.Left( Findcursor ) ) ) - { - //if the different Chinese character at the left or middle, return false. - return EFalse; - } - - return ETrue; - } - itemString.Delete(0, Findcursor+1); - tempBuf.Delete(0, ii+1); - ii=0; + + RPointerArray spellList; + + //translate the chinese charater to spellList( pinyin or stroke ) + if( DoTranslationL(TInt16(tempBuf[ii]), spellList) + && ( tmpBuf.Length() + spellList[0]->Length() < KMaxWordLength) ) + { + tmpBuf.Append( spellList[0]->Des() ); } - else - { - if ( IsChineseWord( tempBuf.Left( ii + 1 ) ) ) - { - //flag the different Chinese character at the left. - leftDifferentChinese = ETrue; - } - - ii++; - } + spellList.ResetAndDestroy(); + spellList.Close(); + ii++; } + //if not, just append it else { + if( tmpBuf.Length() + 1 < KMaxWordLength ) + { + tmpBuf.Append( tempBuf[ii] ); + } + ii++; } } + + tempBuf.Zero(); + tempBuf.Copy(tmpBuf); } // Array for item string @@ -1486,6 +1460,32 @@ return IsChineseSearchStr; } + +// -------------------------------------------------------- +// Find pane text is just Chinese word +// -------------------------------------------------------- +// +TBool CFindUtilChinese::ChineseWord(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( ( ( TInt )aWord[i] < KMinUnicodeHz ) || ( InputMethodStroke && IsStrokeSymbol(aWord[i]) ) ) + { + isChineseWord = EFalse; + break; + } + } + return isChineseWord; + } // --------------------------------------------------------- // Find pane text is including stroke symbol @@ -1919,10 +1919,6 @@ { pStringInfo= astringInfoArr[aindex]; } - else - { - return; - } if (pStringInfo->isChinese) { @@ -2334,7 +2330,9 @@ { //for multiphnetic spell TInt spellCount = tempSpellList.Count(); - + TInt matchMaxIndex = 0; + TInt matchMax = 0; + TInt matchMaxPre = 0; // Search all spelling for (TInt j = 0; j < spellCount; j++) {