uiutils/Findutil/src/FindUtilChinese.cpp
branchRCL_3
changeset 18 fcdfafb36fe7
parent 15 c52421ed5f07
child 19 aecbbf00d063
equal deleted inserted replaced
17:a1caeb42b3a3 18:fcdfafb36fe7
   873     if (IsChineseWord(tempBuf))
   873     if (IsChineseWord(tempBuf))
   874         {
   874         {
   875         haschineseword = ETrue;
   875         haschineseword = ETrue;
   876         ret = IncludeString(aItemString, tempBuf);
   876         ret = IncludeString(aItemString, tempBuf);
   877         
   877         
   878         if (ret || ChineseWord( tempBuf ))
   878         if (ret)
   879             {
   879             {
   880             return ret;
   880             return ret;
   881             }
   881             }
   882     /*    else
   882     /*    else
   883             {
   883             {
   903         }
   903         }
   904     
   904     
   905     if (haschineseword)
   905     if (haschineseword)
   906         {
   906         {
   907         TInt ii=0;
   907         TInt ii=0;
   908         TBuf<KMaxWordLength> tmpBuf;
   908         TBool leftDifferentChinese = EFalse; 
   909         tmpBuf.Zero();
   909 		//this is used for fixing for the issue of search string including Chinese characters
   910         
       
   911         ////translate the whole searchstring to spelllist
       
   912         while (ii< tempBuf.Length())
   910         while (ii< tempBuf.Length())
   913             {
   911             {
   914             
       
   915             //if it is a valid chinese character
       
   916             if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke
   912             if ((TInt)tempBuf[ii]>= KMinUnicodeHz && (!InputMethodStroke
   917                     ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii]))))
   913                     ||(InputMethodStroke && !IsStrokeSymbol(tempBuf[ii]))))
   918                 {
   914                 {
   919                 
   915                 TInt Findcursor = itemString.Locate(tempBuf[ii]);
   920                 RPointerArray<HBufC> spellList;
   916                 if (Findcursor != KErrNotFound)
   921                 
   917                     {
   922                 //translate the chinese charater to spellList( pinyin or stroke )
   918                     if ((Findcursor == itemString.Length()-1)&& (ii
   923                 if( DoTranslationL(TInt16(tempBuf[ii]), spellList)
   919                             ==tempBuf.Length()-1))
   924                     && ( tmpBuf.Length() + spellList[0]->Length() < KMaxWordLength)  )
   920                         {
   925                 	{
   921                         
   926                     tmpBuf.Append( spellList[0]->Des() );
   922                         if ( leftDifferentChinese || IsChineseWord(
       
   923                             itemString.Left( Findcursor ) ) )
       
   924                             {
       
   925                             //if the different Chinese character at the left or middle, return false.
       
   926                             return EFalse;
       
   927                             }
       
   928                         
       
   929                         return ETrue;
       
   930                         }
       
   931                     itemString.Delete(0, Findcursor+1);
       
   932                     tempBuf.Delete(0, ii+1);
       
   933                     ii=0;
   927                     }
   934                     }
       
   935                 else
       
   936                     {
   928                     
   937                     
   929                 spellList.ResetAndDestroy();
   938                     if ( IsChineseWord( tempBuf.Left( ii + 1 ) ) )
   930                 spellList.Close();
   939                         {
       
   940                         //flag the different Chinese character at the left.
       
   941                         leftDifferentChinese = ETrue;
       
   942                         }
       
   943                     
       
   944                     ii++;
       
   945                     }
       
   946                 }
       
   947             else
       
   948                 {
   931                 ii++;
   949                 ii++;
   932                 }
   950                 }
   933             //if not, just append it     
   951             }
   934             else
       
   935                 {
       
   936                 if( tmpBuf.Length() + 1 < KMaxWordLength )
       
   937                 	{
       
   938                     tmpBuf.Append( tempBuf[ii] );
       
   939                     }
       
   940                     
       
   941                 ii++;
       
   942                 }
       
   943             }
       
   944             
       
   945             tempBuf.Zero();
       
   946             tempBuf.Copy(tmpBuf);
       
   947         }
   952         }
   948 
   953 
   949     // Array for item string
   954     // Array for item string
   950     RPointerArray<STRINGINFO> stringInfoArr;
   955     RPointerArray<STRINGINFO> stringInfoArr;
   951     // Split item string
   956     // Split item string
  1479             }
  1484             }
  1480         }
  1485         }
  1481 
  1486 
  1482     return IsChineseSearchStr;
  1487     return IsChineseSearchStr;
  1483     }
  1488     }
  1484 
       
  1485 // --------------------------------------------------------
       
  1486 // Find pane text is just Chinese word
       
  1487 // --------------------------------------------------------
       
  1488 //
       
  1489 TBool CFindUtilChinese::ChineseWord(const TDesC& aWord)
       
  1490 	{
       
  1491 	TBool isChineseWord = ETrue;
       
  1492 	const TInt len = aWord.Length();
       
  1493 	
       
  1494     TBool InputMethodStroke = EFalse;
       
  1495     if(iLanguage == ELangHongKongChinese && iCurInputMode == 0x0020)
       
  1496         {
       
  1497         InputMethodStroke = ETrue;
       
  1498         }
       
  1499 	
       
  1500 	for( TInt i = 0; i < len; i++ )
       
  1501 		{
       
  1502 		if( ( ( TInt )aWord[i] < KMinUnicodeHz ) || ( InputMethodStroke && IsStrokeSymbol(aWord[i]) ) )
       
  1503 			{
       
  1504 			isChineseWord = EFalse;
       
  1505 			break;
       
  1506 			}
       
  1507 		}
       
  1508 	return isChineseWord;
       
  1509 	}
       
  1510     
  1489     
  1511 // ---------------------------------------------------------
  1490 // ---------------------------------------------------------
  1512 // Find pane text is including stroke symbol  
  1491 // Find pane text is including stroke symbol  
  1513 // ---------------------------------------------------------
  1492 // ---------------------------------------------------------
  1514 //
  1493 //