textinput/ptienginev2/src/PtiEngineImpl.cpp
branchRCL_3
changeset 10 6defe5d1bd39
parent 0 eb1f2e154e89
child 12 4eb1ae11334f
child 23 f043c81198e3
equal deleted inserted replaced
8:6ceef9a83b1a 10:6defe5d1bd39
  1720 										     TDesC& aKeyMap,
  1720 										     TDesC& aKeyMap,
  1721 											 TPtiTextCase aCase)
  1721 											 TPtiTextCase aCase)
  1722 	{
  1722 	{
  1723 	if (iCurrentLanguage || iInputMode == EPtiEngineNumeric)
  1723 	if (iCurrentLanguage || iInputMode == EPtiEngineNumeric)
  1724 		{			
  1724 		{			
  1725 		MPtiCore *core = CoreForInputMode( aMode );		
  1725 	    
       
  1726 		MPtiCore *core = NULL;
       
  1727 		if( iCurrentLanguage != NULL )
       
  1728 		    {
       
  1729 		    core = CoreForInputMode( aMode );
       
  1730 		    }
  1726 		if (!core)
  1731 		if (!core)
  1727 			{
  1732 			{
  1728 			return KErrNoSuitableCore;
  1733 			return KErrNoSuitableCore;
  1729 			}
  1734 			}
  1730 
  1735 
  1922 // 
  1927 // 
  1923 // ---------------------------------------------------------------------------
  1928 // ---------------------------------------------------------------------------
  1924 //
  1929 //
  1925 TInt CPtiEngineImpl::AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry)
  1930 TInt CPtiEngineImpl::AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry)
  1926 	{
  1931 	{
       
  1932     
       
  1933     if ( !iCurrentLanguage )
       
  1934         {
       
  1935         return KErrNoActiveLanguage;
       
  1936         }
       
  1937     
  1927 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  1938 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  1928 
  1939 
  1929 	if (dict)
  1940 	if (dict)
  1930 		{
  1941 		{
  1931 		return Core()->AddUserDictionaryEntry(aEntry, dict);
  1942 		return Core()->AddUserDictionaryEntry(aEntry, dict);
  1932 		}
       
  1933 
       
  1934 	if (!iCurrentLanguage)
       
  1935 		{
       
  1936 		return KErrNoActiveLanguage;
       
  1937 		}
  1943 		}
  1938 
  1944 
  1939 	return KErrNotSupported;
  1945 	return KErrNotSupported;
  1940 	}
  1946 	}
  1941 
  1947 
  1969 // 
  1975 // 
  1970 // ---------------------------------------------------------------------------
  1976 // ---------------------------------------------------------------------------
  1971 //
  1977 //
  1972 TInt CPtiEngineImpl::RemoveEntryFromUserDictionary(MPtiUserDictionaryEntry& aEntry)
  1978 TInt CPtiEngineImpl::RemoveEntryFromUserDictionary(MPtiUserDictionaryEntry& aEntry)
  1973 	{
  1979 	{
       
  1980     
       
  1981     if ( !iCurrentLanguage )
       
  1982         {
       
  1983         return KErrNoActiveLanguage;
       
  1984         }
       
  1985     
  1974 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  1986 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  1975 
  1987 
  1976 	if (dict)
  1988 	if (dict)
  1977 		{
  1989 		{
  1978 		return Core()->RemoveUserDictionaryEntry(aEntry, dict);
  1990 		return Core()->RemoveUserDictionaryEntry(aEntry, dict);
  1979 		}
       
  1980 
       
  1981 	if (!iCurrentLanguage)
       
  1982 		{
       
  1983 		return KErrNoActiveLanguage;
       
  1984 		}
  1991 		}
  1985 
  1992 
  1986 	return KErrNotSupported;
  1993 	return KErrNotSupported;
  1987 	}
  1994 	}
  1988 
  1995 
  2016 // 
  2023 // 
  2017 // ---------------------------------------------------------------------------
  2024 // ---------------------------------------------------------------------------
  2018 //
  2025 //
  2019 TInt CPtiEngineImpl::NumberOfEntriesInUserDictionary()
  2026 TInt CPtiEngineImpl::NumberOfEntriesInUserDictionary()
  2020 	{
  2027 	{
       
  2028     
       
  2029     if ( !iCurrentLanguage )
       
  2030         {
       
  2031         return KErrNoActiveLanguage;
       
  2032         }
  2021 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  2033 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  2022 	
  2034 	
  2023 	if (dict)
  2035 	if (dict)
  2024 		{
  2036 		{
  2025 		return Core()->NumberOfEntriesInUserDictionary(dict);
  2037 		return Core()->NumberOfEntriesInUserDictionary(dict);
  2026 		}
  2038 		}
  2027 
       
  2028 	if (!iCurrentLanguage)
       
  2029 		{
       
  2030 		return KErrNoActiveLanguage;
       
  2031 		}
       
  2032 
       
  2033 	return KErrNotSupported;
  2039 	return KErrNotSupported;
  2034 	}
  2040 	}
  2035 
  2041 
  2036 
  2042 
  2037 // ---------------------------------------------------------------------------
  2043 // ---------------------------------------------------------------------------
  2321 // 
  2327 // 
  2322 // ---------------------------------------------------------------------------
  2328 // ---------------------------------------------------------------------------
  2323 //
  2329 //
  2324 TInt CPtiEngineImpl::GetUserDictionaryEntry(TInt aIndex, MPtiUserDictionaryEntry& aResult)
  2330 TInt CPtiEngineImpl::GetUserDictionaryEntry(TInt aIndex, MPtiUserDictionaryEntry& aResult)
  2325 	{
  2331 	{
       
  2332     
       
  2333     if ( !iCurrentLanguage )
       
  2334         {
       
  2335         return KErrNoActiveLanguage;
       
  2336         }
       
  2337     
  2326 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  2338 	CPtiUserDictionary* dict = DefaultUserDictForCore(Core());
  2327 
  2339 
  2328 	if (dict)
  2340 	if (dict)
  2329 		{
  2341 		{
  2330 		return Core()->GetUserDictionaryEntry(aIndex, aResult, dict);
  2342 		return Core()->GetUserDictionaryEntry(aIndex, aResult, dict);
  2331 		}
       
  2332 	
       
  2333 	if (!iCurrentLanguage)
       
  2334 		{
       
  2335 		return KErrNoActiveLanguage;
       
  2336 		}
  2343 		}
  2337 
  2344 
  2338 	return KErrNotSupported;
  2345 	return KErrNotSupported;
  2339 	}
  2346 	}
  2340 
  2347 
  3110 				 break;								     
  3117 				 break;								     
  3111 			case EPtiEngineMultitapping:	
  3118 			case EPtiEngineMultitapping:	
  3112 			case EPtiEnginePredictive:	
  3119 			case EPtiEnginePredictive:	
  3113 				 {
  3120 				 {
  3114 				 CPtiKeyMappings* maps = static_cast<CPtiKeyMappings*>(iCurrentLanguage->GetKeymappings());
  3121 				 CPtiKeyMappings* maps = static_cast<CPtiKeyMappings*>(iCurrentLanguage->GetKeymappings());
  3115 				 maps->GetDataForKey(aKey, aResult, aCase);
  3122 				 
       
  3123 				 if( maps != NULL )
       
  3124 				     {
       
  3125 				     maps->GetDataForKey(aKey, aResult, aCase);
       
  3126 				     }
  3116 				 }
  3127 				 }
  3117 				 break;
  3128 				 break;
  3118 		    // Predictive QWERTY (XT9) changes ---->
  3129 		    // Predictive QWERTY (XT9) changes ---->
  3119 			case EPtiEngineQwertyPredictive: // fall through
  3130 			case EPtiEngineQwertyPredictive: // fall through
  3120 			// Predictive QWERTY (XT9) changes <----
  3131 			// Predictive QWERTY (XT9) changes <----
  3126 			case EPtiEngineEasyCangjieQwerty:
  3137 			case EPtiEngineEasyCangjieQwerty:
  3127 			case EPtiEngineAdvCangjieQwerty:
  3138 			case EPtiEngineAdvCangjieQwerty:
  3128 			case EPtiEngineQwerty:
  3139 			case EPtiEngineQwerty:
  3129      			 {
  3140      			 {
  3130 		     	 CPtiQwertyKeyMappings* maps = static_cast<CPtiQwertyKeyMappings*>(iCurrentLanguage->GetQwertyKeymappings());
  3141 		     	 CPtiQwertyKeyMappings* maps = static_cast<CPtiQwertyKeyMappings*>(iCurrentLanguage->GetQwertyKeymappings());
  3131 				 maps->GetDataForKey(aKey, aResult, aCase);
  3142 				 if( maps != NULL )
       
  3143 				     {
       
  3144 		     	     maps->GetDataForKey(aKey, aResult, aCase);
       
  3145 				     }
  3132 				 }     			
  3146 				 }     			
  3133 			     break;							
  3147 			     break;							
  3134      		case EPtiEnginePinyinPhraseHalfQwerty:
  3148      		case EPtiEnginePinyinPhraseHalfQwerty:
  3135      		case EPtiEngineStrokePhraseHalfQwerty:    
  3149      		case EPtiEngineStrokePhraseHalfQwerty:    
  3136      		case EPtiEngineZhuyinPhraseHalfQwerty:
  3150      		case EPtiEngineZhuyinPhraseHalfQwerty:
  3137 			case EPtiEngineHalfQwerty:
  3151 			case EPtiEngineHalfQwerty:
  3138 			case EPtiEngineHalfQwertyPredictive:
  3152 			case EPtiEngineHalfQwertyPredictive:
  3139      			 {
  3153      			 {
  3140 		     	 CPtiHalfQwertyKeyMappings* maps = static_cast<CPtiHalfQwertyKeyMappings*>(iCurrentLanguage->GetHalfQwertyKeymappings());
  3154 		     	 CPtiHalfQwertyKeyMappings* maps = static_cast<CPtiHalfQwertyKeyMappings*>(iCurrentLanguage->GetHalfQwertyKeymappings());
  3141 				 maps->GetDataForKey(aKey, aResult, aCase);
  3155 				 if( maps != NULL )
       
  3156 				     {
       
  3157 		     	     maps->GetDataForKey(aKey, aResult, aCase);
       
  3158 				     }
  3142 				 }     			
  3159 				 }     			
  3143 			     break;							
  3160 			     break;							
  3144 			default:
  3161 			default:
  3145 			   break;
  3162 			   break;
  3146 			}		
  3163 			}		
  3824             }
  3841             }
  3825         
  3842         
  3826         CPtiQwertyKeyMappings* qmaps = static_cast<CPtiQwertyKeyMappings*>(lang->GetQwertyKeymappings());
  3843         CPtiQwertyKeyMappings* qmaps = static_cast<CPtiQwertyKeyMappings*>(lang->GetQwertyKeymappings());
  3827         if (qmaps)
  3844         if (qmaps)
  3828             {
  3845             {
  3829             CPtiKeyMapData* mapData = maps->KeyMapData();
  3846         
       
  3847             CPtiKeyMapData* mapData = NULL;
       
  3848             if( maps != NULL )
       
  3849                 {
       
  3850                 mapData = maps->KeyMapData();
       
  3851                 }
  3830             if (mapData)
  3852             if (mapData)
  3831                 {
  3853                 {
  3832                 if (mapData->KeyData(EPtiKeyboardQwerty4x12, tmpSize))
  3854                 if (mapData->KeyData(EPtiKeyboardQwerty4x12, tmpSize))
  3833                     {
  3855                     {
  3834                     User::LeaveIfError(aResult.Append(EPtiKeyboardQwerty4x12));
  3856                     User::LeaveIfError(aResult.Append(EPtiKeyboardQwerty4x12));