predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsKeyMap.cpp
branchRCL_3
changeset 7 b3431bff8c19
parent 0 e686773b3f54
child 18 d4f567ce2e7c
--- a/predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsKeyMap.cpp	Mon Mar 15 12:39:26 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsKeyMap.cpp	Wed Mar 31 21:13:53 2010 +0300
@@ -19,6 +19,7 @@
 // INCLUDE FILES
 
 #include "CPcsAlgorithm2.h"
+#include "CPcsAlgorithm2Utils.h"
 #include "FindUtilChineseECE.h"
 #include "CPcsDebug.h"
 #include "CPcsKeyMap.h"
@@ -693,9 +694,14 @@
 // CPcsKeyMap::PoolIdForCharacter
 // 
 // ----------------------------------------------------------------------------
-TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar)
+TInt CPcsKeyMap::PoolIdForCharacter(TChar aChar)
     {
     TInt numValue = KErrNotFound;
+    
+    // If character is a Chinese word character, then we select the
+    // pool ID according the first character of the first spelling of the word.
+    TRAP_IGNORE( aChar = FirstCharFromSpellingL( aChar ) );
+    
     TInt key = KeyForCharacter(aChar);
     if (key != KErrNotFound)
         {
@@ -712,6 +718,27 @@
     }
 
 // ----------------------------------------------------------------------------
+// CPcsKeyMap::CPcsKeyMap::FirstCharFromSpellingL
+// 
+// ----------------------------------------------------------------------------
+TChar CPcsKeyMap::FirstCharFromSpellingL( TChar aChar ) const
+    {
+    TChar translated( aChar );
+    TBuf<1> temp;
+    temp.Append( aChar );
+    if ( iAlgorithm->FindUtilECE()->IsChineseWord( temp ) )
+        {
+        RPointerArray<HBufC> spellList;
+        CleanupResetAndDestroyPushL( spellList );
+        if (iAlgorithm->FindUtilECE()->DoTranslationL(aChar, spellList))
+            {
+            translated = (*spellList[0])[0];
+            }
+        CleanupStack::PopAndDestroy( &spellList ); // ResetAndDestroy
+        }
+    return translated;
+    }
+// ----------------------------------------------------------------------------
 // CPcsKeyMap::PoolCount
 // 
 // ----------------------------------------------------------------------------