fep/aknfep/src/AknFepManager.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:           
       
    15 *       Provides the CAknFepManager methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include <uikon/eikdefmacros.h>
       
    31 #endif
       
    32 #include "AknFepManager.h"
       
    33 #include "AknFepManagerInterface.h" // MAknFepManagerInterface
       
    34 #include "aknfepindicator.h"
       
    35 #include "AknFepPanic.h"
       
    36 #include "AknFepKeyCatcher.h"
       
    37 #include "AknFepGlobalEnums.h"
       
    38 #include "AknFepCaseManager.h"
       
    39 #include "AknFepHashKeyManager.h"
       
    40 #include "AknFepSharedDataInterface.h"
       
    41 #include "AknFepInlineTextDecorator.h"
       
    42 #include "AknFepUiManagerBase.h"
       
    43 #include "AknFepUiManagerChinese.h"
       
    44 #include "AknFepUiManagerWestern.h"
       
    45 
       
    46 #include "AknFepPluginManager.h"
       
    47 #include "AknFepUiIndicInputManager.h"
       
    48 #include "AknFepUiIndicEnums.h"
       
    49 #include <AknFepUIStylusPopupMenu.h>
       
    50 #include "aknfepuispellinputpane.h"
       
    51 
       
    52 #include <bautils.h>
       
    53 #include <coeaui.h>                 //CCoeAppUi
       
    54 #include <aknedsts.h>               //CAknEdwinState
       
    55 #include <uikon.hrh>                //keys
       
    56 #include <aknenv.h>                 //CAknEnv
       
    57 #include <PtiEngine.h>              //CPtiEngine
       
    58 #include <AknJapaneseReading.h>     //CAknJapaneseReading
       
    59 #include <featmgr.h>                //FeatureManager
       
    60 #include <e32base.h>                //CPeriodic
       
    61 #include <PtiDefs.h>                //keys
       
    62 #include <fepipext.h>               //MCoeFepSpecificExtensions
       
    63 
       
    64 #include <aknsoundsystem.h>
       
    65 #include <avkon.rsg>
       
    66 #include <avkon.hrh>
       
    67 
       
    68 #include <tagma.h>
       
    69 #include <frmtview.h>
       
    70 #include <aknedformaccessor.h>
       
    71 
       
    72 #include <aknfep.rsg>
       
    73 #include <avkon.mbg>
       
    74 
       
    75 #include "aknconsts.h"
       
    76 #include <aknfeppeninputenums.h>
       
    77 #include <eikproc.h>                // User Dictionary
       
    78 #include <eikapp.h>                 // User Dictionary
       
    79 
       
    80 #include <StringLoader.h>
       
    81 
       
    82 #include <centralrepository.h>
       
    83 #include <AknFepInternalCRKeys.h>
       
    84 #include <settingsinternalcrkeys.h>
       
    85 #include <AknUtils.h>
       
    86 #include <AknCustomCursorSupport.h>
       
    87 #include <PtiKeyMappings.h>
       
    88 #include <aknfeppeninputimeplugin.h>
       
    89 #include <peninputcmd.h>
       
    90 
       
    91 #include <AknSettingCache.h>
       
    92 #include <aknextendedinputcapabilities.h>
       
    93 #include <AvkonInternalCRKeys.h>
       
    94 #include <hlplch.h>
       
    95 #include <aknfepdocumentnavigation.h>
       
    96 
       
    97 #include <eikcolib.h>
       
    98 #include <akntoolbar.h>
       
    99 
       
   100 #include <eikfrlbd.h>
       
   101 #include <eikccpu.h>
       
   102 #include <aknappui.h>
       
   103 #include <apgwgnam.h>
       
   104 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   105 #include "AknFepUiWordPopupContent.h"
       
   106 #include "AknFepFnKeyManager.h"
       
   107 //#include <csxhelp/cp.hlp.hrh> 
       
   108 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   109 
       
   110 #ifdef RD_TACTILE_FEEDBACK
       
   111 #include <touchfeedback.h>
       
   112 #endif //RD_TACTILE_FEEDBACK
       
   113 #include "AknFepThaiSCTSelector.h"
       
   114 
       
   115 //the follow 10 filse include for phrase creation
       
   116 #include <bamdesca.h>
       
   117 #include <eikspane.h> //CEikStatusPane 
       
   118 #include <akntitle.h> //CAknTitlePane 
       
   119 #include <akntoolbar.h> //CAknToolBar 
       
   120 #include <aknappui.h>
       
   121 #include "AknFep.hrh"
       
   122 #include "aknfepuserdbdlg.h"
       
   123 #include "aknfepzhuyinkeyhandler.h"
       
   124 #include "AknFepZhuyinAnalyser.h"
       
   125 #include "AknFepZhuyinAnalyserDb.h"
       
   126 
       
   127 #include <aknnavi.h> 
       
   128 #include <aknnavide.h> 
       
   129 
       
   130 #include <eikedwin.h>
       
   131 #include <aknCharMap.h>
       
   132 
       
   133 const TInt KSelectItemSize(10);
       
   134 _LIT(KAknFepResourceFileName, "z:\\resource\\fep\\aknfep.rsc");
       
   135 _LIT(KFEPPREDINPUT_HLP_INPUT, "PREDINPUT_HLP_INPUT"); // 
       
   136 
       
   137 #define text_to_field_mode_hash_key ';'
       
   138 #define iAvkonAppUi ((CAknAppUi*)CEikonEnv::Static()->EikAppUi())
       
   139 #define __SHIFT_KEY_LOOP
       
   140 
       
   141 // EAknEditorNativeKeysNumberModeKeymap is used for example in MFNE editors.
       
   142 #define EAknEditorNativeKeysNumberModeKeymap EAknEditorReservedInternalUseKeymap
       
   143 
       
   144 // UID of user dictionary application
       
   145 const TUid KUidUserDictApp = {0x101F8645};
       
   146 
       
   147 const TText KAknFEPLineFeedSymbol = 0x21B2;
       
   148 const TText KAknFEPMirroredLineFeedSymbol = 0x21B3;
       
   149 const TText KAknFEPZeroKey = 0x30;
       
   150 
       
   151 // inline text decoration potentially adds 2 directional markers for every "real" character. Buffer needs to be 3 x predictive engine bufsize
       
   152 const TInt KMaxInlineEditSize( 3 * CAknFepManager::EMaximumFepWordLength );
       
   153 
       
   154 // Maximum number of chunks to navigate throught attempting to get to the visual end of a selection.
       
   155 // Since chunks are arranged only within a line, this should be more than the number of chunks likely in
       
   156 // a single line of text
       
   157 const TInt KMaxChunkWalkIterations(20);
       
   158 
       
   159 // This command is is used for setting empty CBA.
       
   160 const TInt KNullCommandId = 0;
       
   161 
       
   162 _LIT_SECURE_ID(KPhoneSecureId, 0x100058b3);
       
   163 
       
   164 #ifdef RD_HINDI_PHONETIC_INPUT
       
   165 
       
   166 const TUint KQuestionMark = 0x003F;
       
   167 
       
   168 #endif
       
   169 
       
   170 // Ccpu key events. 
       
   171 /*As part of build warnings commenting this perticular code it might require when touch is enabled.
       
   172 const TKeyEvent KEditorCopyEvent = {3, 67, 161, 0};  // Ctrl + C
       
   173 const TKeyEvent KEditorCutEvent  = {24, 88, 161, 0}; // Ctrl + X
       
   174 */
       
   175 
       
   176 const TInt KTouchInputPreviewOn = 1;
       
   177 const TInt KTouchInputPreviewOff = 0;
       
   178 
       
   179 #ifdef  RD_SCALABLE_UI_V2
       
   180 const TKeyEvent KAknCcpuCopyEvent = {EKeyF18, EEikCmdEditCopy, EModifierCtrl, 1};  // Copy event for AknCcpuSupport
       
   181 const TKeyEvent KAknCcpuCutEvent  = {EKeyF18, EEikCmdEditCut, EModifierCtrl, 1};   // Cut event for AknCcpuSupport
       
   182 
       
   183 const TInt KMaxMenuSize = 23;
       
   184 const TInt KEditorMenuPermitedSend[KMaxMenuSize] = 
       
   185     {         
       
   186     EJapanFepCmdModeHiragana,
       
   187     EJapanFepCmdModeKatakana,
       
   188     EJapanFepCmdEditModeAlpha,
       
   189     EJapanFepCmdEditModeNumber,
       
   190     EJapanFepCmdModeFullWidth,
       
   191     EJapanFepCmdModeHalfWidth,
       
   192     EChinFepCmdModePinyin,
       
   193     EChinFepCmdModeZhuyin,
       
   194     EChinFepCmdModeStroke,
       
   195     EAknCmdT9PredictiveT9Off,
       
   196     EAknCmdMultitapPredictiveT9On,
       
   197     EJapanFepCmdMultitapPredictiveT9On,
       
   198     EChinFepCmdModeZhuyinFind,
       
   199     EChinFepCmdModeStrokeFind,
       
   200     EAknCmdEditModeAlpha,
       
   201     EAknCmdEditModeLatinText,
       
   202     EChinFepCmdModeLatinUpper,
       
   203     EChinFepCmdModeLatinLower,
       
   204     EAknCmdEditModeNumber,
       
   205     EChinFepCmdModeNumber,
       
   206     EAknCmdEditModeArabicIndicNumber,
       
   207     EAknCmdEditModeEasternArabicIndicNumber,
       
   208     EAknCmdEditModeIndicNumber
       
   209     };   
       
   210      
       
   211 #endif // RD_SCALABLE_UI_V2 
       
   212 
       
   213 
       
   214 // Number modes used by Arabic or Hindi.
       
   215 enum TNonLatinNumberModes
       
   216     { 
       
   217     ENbrModeLatin,
       
   218     ENbrModeArabic = 1,
       
   219     ENbrModeIndic = 1
       
   220     };
       
   221 
       
   222 // Number mode type
       
   223 enum TNonLatinNumberModeType
       
   224     {
       
   225     ENbrModeTypeArabic,
       
   226     ENbrModeTypeIndic,
       
   227     ENbrModeTypeEasternArabic //for Urdu & Farsi languages
       
   228     };
       
   229     
       
   230 // The passwd timeout is same as defined on CEikSecretEditor.
       
   231 const TInt KSyncPasswdTimeout = 1000000;
       
   232 
       
   233 #ifdef RD_SCALABLE_UI_V2
       
   234 TUid AppUidFromWndGroupId(TInt aWndGrpId);
       
   235 extern TUid GetCurAppUid();
       
   236 extern TBool IsGlobalNotesApp(TUid& aUid);
       
   237 TInt GetForegroundTaskAppWgId();
       
   238 #endif
       
   239 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   240 const TInt KWordToFocusInCandidateList = 1;
       
   241 #endif
       
   242 
       
   243 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr);
       
   244 
       
   245 //
       
   246 // Class TTextDirectionalInfo
       
   247 //
       
   248 /**
       
   249 * The implementation inializes with well-defined "null" state
       
   250 */
       
   251 CAknFepManager::TTextDirectionalInfo::TTextDirectionalInfo() : 
       
   252 iDirectionalStatus(EUnknown), iBlockEnvironment(EUndefined)
       
   253     {}
       
   254 
       
   255 void CAknFepManager::TTextDirectionalInfo::SetDirectionFromChunk( 
       
   256                const CTmTextLayout::TTmChunkDescription& aChunk )
       
   257     {
       
   258     if ( aChunk.iStart >= 0 ) // Condition for valid block. Does nothing otherwise
       
   259         iDirectionalStatus = aChunk.iRightToLeft ? ERightToLeft : ELeftToRight;
       
   260     }
       
   261 
       
   262 
       
   263 void TFepLanguageTranslation::ReadFromResource(TResourceReader& aReader)
       
   264     {
       
   265     iName.Set(aReader.ReadTPtrC());
       
   266     iLanguageId = aReader.ReadInt16();
       
   267     iCommandId = aReader.ReadInt16();
       
   268     }
       
   269 
       
   270 
       
   271 CAknFepManager::CAknFepManager(CCoeEnv& aConeEnvironment)
       
   272     :CCoeFep(aConeEnvironment),
       
   273     iAsyncResouceChanged(EActivePriorityDefault),
       
   274     iPreviousEditingState(EStateNone),
       
   275     iInputCapabilities(TCoeInputCapabilities::ENone),
       
   276     iModeBefore(ELatin),
       
   277     #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   278     iKeyPressedDuringShift(EFalse),
       
   279 #endif
       
   280     iCharWidth(EHalfWidthChar),
       
   281     iAsyncOwnSimulateKey(EActivePriorityDefault),
       
   282     iLongThai0Key(EFalse),
       
   283     iEditCharsPtr(0,0),
       
   284     iComposChrFlag(0),
       
   285     iIsUserdbdlgActive(0),
       
   286     iLongClearAfterCloseUI(EFalse),
       
   287     // phrase creation
       
   288     iPhraseCreation(0),
       
   289     iPinyinPhraseCreation(0),
       
   290     iEntryPhrase(0)
       
   291     
       
   292 
       
   293     {
       
   294     }
       
   295 
       
   296 void CAknFepManager::ConstructL(const CCoeFepParameters& aFepParameters)
       
   297     {
       
   298     BaseConstructL(aFepParameters);
       
   299     iUiInterface = CAknFepUIInterface::NewL();
       
   300     iIndicator = iUiInterface->NewIndicatorL();
       
   301     iPreviousIndicator = CAknEnv::Static()->SwapEditingStateIndicator(iIndicator);
       
   302 
       
   303     // Set up resources
       
   304     TFileName resourceName(KAknFepResourceFileName);
       
   305     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   306     BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceName);
       
   307     iResId = coeEnv->AddResourceFileL(resourceName);
       
   308 
       
   309     // Save Japanese Feature support to a member variable
       
   310     iFeatureSupportedJapanese = FeatureManager::FeatureSupported(KFeatureIdJapanese);
       
   311 
       
   312     iUiLanguage = User::Language();
       
   313     
       
   314     // Shared Data
       
   315     iSharedDataInterface = CAknFepSharedDataInterface::NewL(this);
       
   316 
       
   317     TInt previUiLanguage = iSharedDataInterface->PluginUILanguage();
       
   318 
       
   319     if (iUiLanguage != previUiLanguage)
       
   320         {
       
   321         
       
   322         // if UI language has changed we need to set text input language according to UI language
       
   323         iSharedDataInterface->SetPluginUILanguage(iUiLanguage);
       
   324         iSharedDataInterface->SetInputTextLanguage(0);  // signals that it needs to be updated
       
   325         }
       
   326 
       
   327     if (!iSharedDataInterface->InputMode()) //not initialised yet - first time device is switched on
       
   328         {
       
   329         switch (iUiLanguage)
       
   330             {
       
   331             case ELangPrcChinese:
       
   332                 iSharedDataInterface->SetInputMode(EPinyin);
       
   333                 break;
       
   334             case ELangTaiwanChinese:
       
   335                 iSharedDataInterface->SetInputMode(EZhuyin);
       
   336                 break;
       
   337             case ELangHongKongChinese:
       
   338                 iSharedDataInterface->SetInputMode(EStroke);
       
   339                 iSharedDataInterface->SetCangJieMode(ECangJieNormal);
       
   340                 break;
       
   341             case ELangJapanese:
       
   342                 iSharedDataInterface->SetInputMode(EHiraganaKanji);
       
   343                 break;
       
   344             case ELangKorean:
       
   345                 iSharedDataInterface->SetInputMode(EHangul);
       
   346                 break;
       
   347             case ELangHindi:
       
   348                 iSharedDataInterface->SetInputMode(EHindi);
       
   349                 break;
       
   350             default:
       
   351                 iSharedDataInterface->SetInputMode(ELatin);
       
   352                 break;
       
   353             }
       
   354         }
       
   355 
       
   356     iUiInterface->SetFepMenuObserver(this);
       
   357    
       
   358     TInt inputLanguage = iSharedDataInterface->InputTextLanguage();
       
   359 
       
   360     // A process instantiating Fep may miss ECapabilityWriteDeviceData capability, 
       
   361     // which is needed for updating locale repository.
       
   362     // A workaround is to delay change up to a process that has the capability
       
   363     TSecurityInfo info;
       
   364     info.Set(RProcess());
       
   365 
       
   366     TBool hasCapability = info.iCaps.HasCapability(ECapabilityWriteDeviceData);
       
   367     
       
   368     if (!inputLanguage && hasCapability)
       
   369         {
       
   370         // set correct input language
       
   371         inputLanguage = SubstituteSublanguageId(iUiLanguage);
       
   372         
       
   373         // If Ptiengine is not initialize, initialize it
       
   374         if (!iPtiEngine)
       
   375             {
       
   376             iPtiEngine = CPtiEngine::NewL(ETrue);    
       
   377             }         
       
   378         // If still not found, default to english.
       
   379         if (!iPtiEngine->GetLanguage(inputLanguage))
       
   380             {
       
   381             inputLanguage = ELangEnglish;   
       
   382             }
       
   383         
       
   384         // Set the current input language
       
   385         iSharedDataInterface->SetInputTextLanguage(inputLanguage);
       
   386         
       
   387         // update numeric input
       
   388         if ( iUiLanguage == ELangArabic ) 
       
   389             {
       
   390             SetDefaultNumberMode( ENbrModeArabic, 
       
   391                                   ENbrModeTypeArabic );
       
   392             }            
       
   393         else if ( ( iUiLanguage == ELangUrdu  ) || 
       
   394                   ( iUiLanguage == ELangFarsi  ) )
       
   395             {
       
   396             SetDefaultNumberMode( ENbrModeArabic, 
       
   397                                   ENbrModeTypeEasternArabic );
       
   398             }
       
   399 		else if ( TAknFepUiIndicInputManager::IsScriptDevanagari( iUiLanguage ) )
       
   400             {
       
   401             SetDefaultNumberMode( ENbrModeLatin, 
       
   402                                   ENbrModeTypeIndic );
       
   403             }
       
   404         else
       
   405             {           
       
   406             SetDefaultNumberMode( ENbrModeLatin, ENbrModeTypeArabic );
       
   407             }
       
   408         }
       
   409         
       
   410     iSctEditChars = HBufC::NewL( 10 );
       
   411     
       
   412 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   413     // Predictive QWERTY (XT9) changes ---->
       
   414     	if(CCoeEnv::Static()->AppUi())
       
   415 				iExactWordPopupContent = iUiInterface->CreateWordPopupContentL();
       
   416     // Predictive QWERTY (XT9) changes <----
       
   417 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   418     // If the following line is uncommented, the FEP is fully constructed
       
   419     // for all applications at application startup.
       
   420     // ConstructFullyL();
       
   421     iShiftKeypressMonitor = CPeriodic::NewL(CActive::EPriorityStandard);
       
   422 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   423     iFnKeyManager = CAknFepFnKeyManager::NewL( *this,iSharedDataInterface );
       
   424 #endif
       
   425     TRAPD(result,iKeyCatcher = CAknFepKeyCatcher::NewL(*this));
       
   426     if(result == KErrNone)
       
   427         {
       
   428         iKeyCatcher->ActivateL();
       
   429         }
       
   430     // the follow 3 objects for phrase creation
       
   431     iZhuyinKeyHandler = CZhuyinKeyHandler::NewL();
       
   432     iZhuyinAnalyserDb = CZhuyinAnalyserDbFeed::NewL(EPinyinAnalyserTypeZhuyin);
       
   433     iZhuyinAnalyser = CAknFepZhuyinAnalyser::NewL(iZhuyinAnalyserDb);
       
   434     iAknFepThaiSCTSelector = CAknFepThaiSCTSelector::NewL();
       
   435     iHybridAplphaChangedToAlphanumeric = EFalse;
       
   436     iLastFocusedEditor = NULL;
       
   437     iFepAwareDialogParentEditor = NULL;
       
   438     }
       
   439 
       
   440 void CAknFepManager::ConstructFullyL()
       
   441     {
       
   442     if (!iPtiEngine)
       
   443         {
       
   444         iPtiEngine = CPtiEngine::NewL(ETrue);    
       
   445         } 
       
   446     
       
   447     if ( !(iPtiEngine->GetLanguage(iSharedDataInterface->InputTextLanguage())) )
       
   448         {
       
   449         // If input language cenrep value is set to language unknown to PtiEngine,
       
   450         // try to reset based on UI-language. 
       
   451         TInt inputLang = SubstituteSublanguageId(iUiLanguage);
       
   452         
       
   453         // If still not found, default to english.
       
   454         if (!iPtiEngine->GetLanguage(inputLang))
       
   455             {
       
   456             inputLang = ELangEnglish;   
       
   457             }
       
   458         iSharedDataInterface->SetInputTextLanguage(inputLang);      
       
   459         }      
       
   460 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   461 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   462     if (iPtiEngine->GetLanguage(iSharedDataInterface->InputTextLanguageSecondary()) == NULL)
       
   463         {
       
   464         // If secondary input language is unknown to PtiEngine, set it to none
       
   465         iSharedDataInterface->SetInputTextLanguageSecondary(0);
       
   466         }
       
   467 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   468 #endif
       
   469         
       
   470     if(NULL == iKeyCatcher)
       
   471         {
       
   472         iKeyCatcher = CAknFepKeyCatcher::NewL(*this);    
       
   473         iKeyCatcher->ActivateL();
       
   474         }
       
   475     
       
   476     iConcatenationTimer=CPeriodic::NewL(CActive::EPriorityStandard);
       
   477     iPostEventCheck=CIdle::NewL(CActive::EPriorityStandard);
       
   478     iChrKeypressMonitor = CPeriodic::NewL(CActive::EPriorityStandard);
       
   479 
       
   480     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   481     TInt inputLanguage = iSharedDataInterface->InputTextLanguage();
       
   482 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   483 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   484     TInt inputLanguageSecondary = iSharedDataInterface->InputTextLanguageSecondary();
       
   485 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   486 #endif
       
   487     SetWesternPredictive(iSharedDataInterface->PredictiveTextOn());
       
   488 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   489     iIsAutoCompleteOn = iSharedDataInterface->PredictiveTextAutoCompleteOn(); // AutoCompletion disabled by Default 
       
   490 #endif	//RD_INTELLIGENT_TEXT_INPUT
       
   491 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   492     iIsAutoCompleteOn = iSharedDataInterface->PredictiveTextAutoCompleteOn(); // AutoCompletion disabled by Default 
       
   493     iTypingCorrectionLevel = iSharedDataInterface->PredictiveTextTypingCorrectionLevel();
       
   494     iIsNumberCandidateShown = iSharedDataInterface->PredictiveTextNumberCandidateShown();
       
   495     TInt primaryCandidateValue = iSharedDataInterface->PredictiveTextPrimaryCandidate();
       
   496     if( primaryCandidateValue == 0)
       
   497 		iPrimaryCandidate = ETrue;
       
   498 	else if(primaryCandidateValue == 1)
       
   499 		iPrimaryCandidate = EFalse; 
       
   500 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   501     iJapanesePredictive = iSharedDataInterface->PredictiveTextJapaneseOn();
       
   502     iQwertyInputMode = iSharedDataInterface->QwertyInputMode();
       
   503     iMultiTapTimer = iSharedDataInterface->MultiTapTimer();
       
   504     iJapaneseQwertyFlags = iSharedDataInterface->JapaneseQwertyFlags();
       
   505 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   506     if(!iFnKeyManager)
       
   507         {
       
   508         iFnKeyManager = CAknFepFnKeyManager::NewL( *this,iSharedDataInterface );
       
   509         }    
       
   510 #endif
       
   511     iCaseMan = CAknFepCaseManager::NewL(*this);
       
   512     iLangMan = CAknFepLanguageManager::NewL(this, iCaseMan);
       
   513     iPtiEngine->ActivateLanguageL(inputLanguage);
       
   514 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   515 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   516     iPtiEngine->SetSecondaryInputL(inputLanguageSecondary);
       
   517 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   518 #endif
       
   519     iLangMan->SetInputLanguageL(inputLanguage);
       
   520     SetInputLanguageCapabilities(inputLanguage);
       
   521     iCurrentFepUI = iLangMan->GetFepUI(ELatin, iCharWidth, IsPredictive(ELatin));
       
   522 
       
   523     iLastKeyPressedWasHashKey = EFalse;
       
   524     iDeviceSupportsRtlLanguage = DeviceSupportsRTLLanguageL();
       
   525 
       
   526     TResourceReader reader;
       
   527     // get character from resource to represent an 'enter' character
       
   528     coeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_SPACE_SYMBOL);
       
   529     iSpaceCharacterCode = reader.ReadUint16();
       
   530     coeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_FULLWIDTHSPACE_SYMBOL);
       
   531     iFullWidthSpaceCharacterCode = reader.ReadUint16();
       
   532     CleanupStack::PopAndDestroy(2); //reader
       
   533 
       
   534     //initialise states
       
   535     iMode = EAknEditorNullInputMode; //Force a sync of mode...
       
   536     SyncStates(EAknFepStateNull);
       
   537     ResetFlags();
       
   538     ResetExtendedFlags();
       
   539 
       
   540     ReadHashKeyLoopL();
       
   541     iHashKeyMan = CAknFepHashKeyManager::NewL(*this, iCaseMan);
       
   542     SetHashKeyStyle();
       
   543     iInlineTextDecorator = new (ELeave) CAknFepInlineTextDecorator;
       
   544     if (IsFeatureSupportedJapanese())
       
   545         {
       
   546         CAknJapaneseReading::CreateL(iPtiEngine);
       
   547         }
       
   548     // setting call back
       
   549     TCallBack callback(DoSimulateKey, this);
       
   550     iAsyncOwnSimulateKey.Set(callback);
       
   551     
       
   552     TCallBack resourcechangedcallback(HandleResourceChangedCallback,this);
       
   553     iAsyncResouceChanged.Set(resourcechangedcallback);
       
   554 #ifdef RD_SCALABLE_UI_V2
       
   555     iFepPluginManager = CAknFepPluginManager::NewL
       
   556         ( *this, *iSharedDataInterface, *iLangMan, *iCaseMan);
       
   557     iNotifyPlugin = ETrue;
       
   558 #endif //RD_SCALABLE_UI_V2
       
   559 
       
   560     iFepFullyConstructed = ETrue;
       
   561 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   562     iIsFnKeyMapped = IsFnKeyMappedL();
       
   563     iKeyboardType = (TPtiKeyboardType)iSharedDataInterface->KeyboardLayout();
       
   564 #endif
       
   565     }
       
   566 
       
   567 CAknFepManager::~CAknFepManager()
       
   568     {
       
   569 #ifdef RD_PF_SEC_APPARC
       
   570     delete iNullService;
       
   571 #else
       
   572     //Embedding - removing created document
       
   573     if ( iEmbedded )
       
   574         {
       
   575         CEikonEnv::Static()->Process()->DestroyDocument(iEmbedded); // User dictionary
       
   576         iEmbedded = NULL;
       
   577         }
       
   578 #endif
       
   579     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
   580         {
       
   581         SetFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
   582         TRAPD(err, CommitInlineEditL())
       
   583         if (err)
       
   584             {
       
   585             CleanUpFep();
       
   586             }
       
   587         }
       
   588         
       
   589     if ( EditorState() )
       
   590         {
       
   591         EditorState()->SetObserver(NULL);    
       
   592         }        
       
   593     if (iLastFocusedEditor)
       
   594         {
       
   595         iLastFocusedEditor->SetObserver(NULL);
       
   596         iLastFocusedEditor = NULL;
       
   597         } 
       
   598     if (iFepAwareDialogParentEditor)
       
   599         {
       
   600         iFepAwareDialogParentEditor->SetObserver(NULL);
       
   601         iFepAwareDialogParentEditor = NULL;
       
   602         } 
       
   603     
       
   604     delete iSharedDataInterface;
       
   605     MAknEditingStateIndicator* indicator = CAknEnv::Static()->EditingStateIndicator();
       
   606     if (indicator == iIndicator)
       
   607         {
       
   608         CAknEnv::Static()->SwapEditingStateIndicator(NULL);
       
   609         }
       
   610 
       
   611         
       
   612     delete iIndicator;
       
   613     iIndicator = NULL;
       
   614     CCoeEnv::Static()->DeleteResourceFile(iResId);
       
   615 
       
   616     // Everything that is constructed in ConstructFullyL() method
       
   617     // needs to be deleted in CommonDestroyFep() method.
       
   618     CommonDestroyFep();
       
   619 
       
   620 	if (iUiInterface)
       
   621 	    iUiInterface->SetFepMenuObserver(NULL);
       
   622 
       
   623     delete iPtiEngine;
       
   624     delete iSctEditChars;
       
   625 
       
   626 #ifdef RD_SCALABLE_UI_V2
       
   627     if ( FepAwareTextEditor() )
       
   628         {
       
   629     		UnregisterObserver();
       
   630         }
       
   631     delete iFepPluginManager;
       
   632     delete iStylusCcpuMenu;        
       
   633 
       
   634     delete iSpellInitText;        
       
   635 #endif // RD_SCALABLE_UI_V2
       
   636     delete iUiInterface;
       
   637 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   638     // Predictive QWERTY (XT9) changes ---->
       
   639     delete iExactWordPopupContent;
       
   640     iExactWordPopupContent = 0;
       
   641     delete iCandidatePopup;
       
   642     iCandidatePopup = 0;
       
   643     delete iResourceString;
       
   644     iResourceString = 0;
       
   645     // Predictive QWERTY (XT9) changes <----
       
   646 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   647     // the follow objects for phrase creation
       
   648       delete iZhuyinKeyHandler;
       
   649       delete iZhuyinAnalyser;
       
   650     delete iAknFepThaiSCTSelector;
       
   651     }
       
   652 
       
   653 void CAknFepManager::CommonDestroyFep()
       
   654     {
       
   655     iFepFullyConstructed = EFalse;
       
   656 
       
   657     // This method is called both from destructor and CleanUpFep methods.
       
   658     iAsyncOwnSimulateKey.Cancel();
       
   659     iAsyncResouceChanged.Cancel();
       
   660     delete iShiftKeypressMonitor;
       
   661     iShiftKeypressMonitor = NULL;
       
   662     delete iConcatenationTimer;
       
   663     iConcatenationTimer = NULL;
       
   664     delete iChrKeypressMonitor;
       
   665     iChrKeypressMonitor = NULL;
       
   666     delete iLangMan;
       
   667     iLangMan = NULL;
       
   668     iCurrentFepUI = NULL;
       
   669     delete iKeyCatcher;
       
   670     iKeyCatcher = NULL;
       
   671 
       
   672     delete iPostEventCheck;
       
   673     iPostEventCheck = NULL;
       
   674     delete iHashKeyMan;
       
   675     iHashKeyMan = NULL;
       
   676     delete iCaseMan;
       
   677     iCaseMan = NULL;
       
   678     delete iInlineTextDecorator;
       
   679     iInlineTextDecorator = NULL;
       
   680     iHashKeyLoop.Close();
       
   681 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   682     if(iFnKeyManager)
       
   683         {
       
   684         delete iFnKeyManager;
       
   685         iFnKeyManager = NULL;
       
   686         }
       
   687     if( iNumericResourceTimer )        
       
   688         {
       
   689         delete iNumericResourceTimer;
       
   690         iNumericResourceTimer = NULL;    
       
   691         }
       
   692 #endif
       
   693     }
       
   694 
       
   695 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   696 void CAknFepManager::SetKeyboardLayout(TPtiKeyboardType aType)
       
   697     {
       
   698     	
       
   699     if(iQwertyInputMode && iFnKeyManager 
       
   700     		&& (iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyLock
       
   701 		||iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyNext)) 
       
   702 		{
       
   703         	iMode = ENumber;
       
   704 		}
       
   705 	
       
   706 	if(iFnKeyManager)        
       
   707 		{
       
   708 		iFnKeyManager->ClearFnKeyState();
       
   709 		}
       
   710     	
       
   711     if(iPtiEngine)
       
   712         {
       
   713         iPtiEngine->SetKeyboardType(aType);
       
   714         }    
       
   715     iKeyboardType = aType;        
       
   716     }
       
   717 
       
   718 TPtiKeyboardType CAknFepManager::KeyboardLayout() const
       
   719     {
       
   720     return iKeyboardType;
       
   721     }
       
   722 #endif
       
   723 TBool CAknFepManager::TryCloseUiL()
       
   724     {
       
   725 #ifdef RD_HINDI_PHONETIC_INPUT        
       
   726     if ((iSharedDataInterface->InputTextLanguage() == KLangHindiPhonetic) && 
       
   727          IsFlagSet(CAknFepManager::EFlagNoMatches))
       
   728         {
       
   729         ClearFlag(CAknFepManager::EFlagNoMatches);
       
   730     	if (PreviousChar() == KQuestionMark)
       
   731     		RemovePreviousCharacterL();
       
   732     	}
       
   733 #endif    
       
   734     if (iFepManState == EAknFepStateUIActive)
       
   735         {
       
   736         // In Japanese input,
       
   737         // commit inline editing at only the western predictive mode.
       
   738         if (!IsFeatureSupportedJapanese() || WesternPredictive())
       
   739             {
       
   740             if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
   741                 {
       
   742                 TryRemoveNoMatchesIndicatorL();
       
   743                 UpdateCbaL(NULL);
       
   744                 }
       
   745                 
       
   746              	
       
   747 
       
   748 //#ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   749 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   750             if ( iFepPluginManager && 
       
   751              	(iFepPluginManager->PluginInputMode() == EPluginInputModeNone))
       
   752             	{
       
   753             	RemoveSuggestedAdvanceCompletionL();
       
   754             	}            
       
   755 #endif // RD_INTELLIGENT_TEXT_INPUT              
       
   756 //#endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   757                 
       
   758 #ifdef RD_SCALABLE_UI_V2 
       
   759             
       
   760             if ( iFepPluginManager != NULL && 
       
   761                  iFepPluginManager->BeforeSpell() )
       
   762                 {
       
   763                 iFepPluginManager->SetBeforeSpell(EFalse);
       
   764                 }
       
   765             else
       
   766 #endif  
       
   767           
       
   768                 {
       
   769                 CommitInlineEditL();    
       
   770                 }
       
   771             }
       
   772         if (IsCcpuFlagSet(ECcpuStataCommitPredictiveWord))            
       
   773             {
       
   774             // Word commiting must be done after CommitInlineEditL call (because
       
   775             // of Japanese ReadingTextL funtionality), hence the delayed commit here.
       
   776             iPtiEngine->CommitCurrentWord();
       
   777             ClearCcpuFlag(ECcpuStataCommitPredictiveWord);
       
   778             }            
       
   779         InternalFepUI()->CloseUI();
       
   780         SyncStates(EAknFepStateInitial);
       
   781         if (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie)
       
   782             {
       
   783             SetCursorType(EActive);
       
   784             if ( EditorState() )
       
   785             	{
       
   786             	EditorState()->SetFlags( EditorState()->Flags() & ~EAknEditorFlagChinesePopup );
       
   787             	}            
       
   788             }
       
   789 
       
   790         // EFalse in case of latin input in Japanese variant
       
   791         if (IsFeatureSupportedJapanese() 
       
   792          && iMode == ELatin && !WesternPredictive())
       
   793             {
       
   794             return EFalse;
       
   795             }
       
   796 
       
   797         return ETrue;
       
   798         }
       
   799     else
       
   800         {
       
   801     	if (IsKoreanInputLanguage())
       
   802         	{
       
   803         	if (IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   804         		{
       
   805         	   	CommitInlineEditL();
       
   806         		PtiEngine()->ClearCurrentWord();
       
   807         		}
       
   808         	}
       
   809     	
       
   810         //in initial state characters should either:
       
   811         //1. not be consumed by the FEP.
       
   812         //2. be committed immediately by the Input State.
       
   813         //3. be multitap chars, in which case they may need to be committed
       
   814         // here. It is best to let the engine deal with this.
       
   815         if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
   816             {
       
   817             InternalFepUI()->ExpireMultitapTimer();
       
   818             }
       
   819         return EFalse;
       
   820         }
       
   821     }
       
   822 
       
   823 void CAknFepManager::SendUIActivatedNotification()
       
   824     {
       
   825     SyncStates(EAknFepStateUIActive);
       
   826     }
       
   827 
       
   828 void CAknFepManager::SendUIDeActivatedNotification()
       
   829     {
       
   830     SyncStates(EAknFepStateInitial);
       
   831     }
       
   832 
       
   833 void CAknFepManager::PlaySound(TAvkonSystemSID aSound) const
       
   834     {
       
   835     if (SoundSystem())
       
   836         {
       
   837         SoundSystem()->PlaySound(aSound);
       
   838         }
       
   839     }
       
   840     
       
   841 void CAknFepManager::SetLongClearAfterCloseUI(TBool aLongClear)
       
   842     {
       
   843     iLongClearAfterCloseUI = aLongClear;
       
   844     }
       
   845 
       
   846 TKeyResponse CAknFepManager::HandleKeyEventL(TUint aCode, TKeyPressLength aLength,TEventCode aEventCode)
       
   847     {
       
   848     TKeyResponse response = EKeyWasNotConsumed;
       
   849 
       
   850     TInt documentLength = -1;
       
   851     if (iInputCapabilities.FepAwareTextEditor())
       
   852         {
       
   853         documentLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
   854         }
       
   855 
       
   856     if (iFepFullyConstructed && iConcatenationTimer->IsActive())
       
   857         {
       
   858         if (!( aCode == EKeyRightArrow ||
       
   859              aCode == EKeyLeftArrow ||
       
   860              aCode == EKeyUpArrow ||
       
   861              aCode == EKeyDownArrow ))
       
   862             {
       
   863             iConcatenationTimer->Cancel();
       
   864             }
       
   865         }
       
   866 
       
   867 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
   868     
       
   869     if(iKeyBackSpaceHit && aCode != EKeyBackspace)
       
   870     	iKeyBackSpaceHit = 0;
       
   871     
       
   872     if (aCode != EPtiKeyStar && iNumericResourceTimer)
       
   873         {
       
   874         // return with EKeyWasConsumed if any of the arrow keys are pressed with 
       
   875         // iNumericResourceTimer is active
       
   876         if(NumericResourceMultiTapTimerTimeoutL()&&
       
   877            (aCode == EKeyRightArrow || aCode == EKeyLeftArrow || aCode == EKeyUpArrow || aCode ==EKeyDownArrow))
       
   878             return EKeyWasConsumed;
       
   879         }
       
   880 #endif
       
   881 
       
   882 
       
   883 
       
   884     // This method is implemented independent of all modes, so it can be called by anyone, anywhere
       
   885     if ( BidiCursorRequired() )
       
   886         {
       
   887         response = AttemptCursorFlipAtAmbiguousPointL( aCode );
       
   888         if ( response == EKeyWasConsumed )
       
   889             {
       
   890             return response;
       
   891             }
       
   892         }
       
   893 
       
   894     if ( aCode != EPtiKeyHash 
       
   895 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   896 #ifdef __HALF_QWERTY_KEYPAD
       
   897 #ifdef __SHIFT_KEY_LOOP		
       
   898     		&& ( aCode != EPtiKeyQwertyLeftShift 
       
   899     		|| EPtiKeyboardHalfQwerty != KeyboardLayout() )
       
   900 #endif //__SHIFT_KEY_LOOP
       
   901 #endif //__HALF_QWERTY_KEYPAD
       
   902 #endif //RD_INTELLIGENT_TEXT_INPUT   		
       
   903     		)
       
   904     
       
   905         {
       
   906         
       
   907         SetLastPressedHashKeyStatus(EFalse);
       
   908         
       
   909         if(iHashKeyMan)
       
   910             {
       
   911             iHashKeyMan->CancelHashKeyTimer();
       
   912             if (aCode != EKeyOK)
       
   913                 {
       
   914                 iHashKeyMan->ClearSelectionModeHashKeyLoop();
       
   915                 }
       
   916             }
       
   917         }
       
   918     // Always commit the text before handling arrow keys
       
   919     if (iMode == EHangul && IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   920     	{
       
   921     	if ( aCode == EKeyRightArrow ||
       
   922              aCode == EKeyLeftArrow ||
       
   923              aCode == EKeyUpArrow ||
       
   924              aCode == EKeyDownArrow )
       
   925     		{
       
   926     		CommitInlineEditL();
       
   927        		iPtiEngine->ClearCurrentWord();
       
   928     		}
       
   929         }
       
   930     TBool isPassNext = IsFlagSet(EFlagPassNextKey);
       
   931    
       
   932     switch (aCode)
       
   933         {
       
   934         case EKeyEscape:
       
   935 
       
   936 #ifdef RD_SCALABLE_UI_V2     
       
   937         if( iFepFullyConstructed && iFepPluginManager)
       
   938             {
       
   939             iFepPluginManager->ResetMenuState(EFalse);            
       
   940             }
       
   941 #endif         
       
   942             if (TryCloseUiL())
       
   943                 {
       
   944                 response = EKeyWasConsumed;
       
   945                 // phrase creation
       
   946                 PhraseCreation(EFalse);
       
   947                 // phrase creation
       
   948                 PinyinPhraseCreation(EFalse);
       
   949                 }
       
   950             break;
       
   951 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   952 #ifdef __HALF_QWERTY_KEYPAD
       
   953 #ifdef __SHIFT_KEY_LOOP
       
   954         case EPtiKeyQwertyLeftShift:
       
   955         if( EPtiKeyboardHalfQwerty == KeyboardLayout() )
       
   956         	{
       
   957 			response = HandleHashKeyL(aLength);
       
   958             (aLength == ELongKeyPress)? SetLastPressedHashKeyStatus(EFalse):SetLastPressedHashKeyStatus(ETrue);
       
   959 			}
       
   960             break;			
       
   961 #endif //__SHIFT_KEY_LOOP       	
       
   962 #endif //__HALF_QWERTY_KEYPAD	
       
   963 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   964         case EPtiKeyHash:
       
   965             if(InputMode() == EHangul)
       
   966             	{
       
   967 				if (aLength == EShortKeyPress)
       
   968 					{
       
   969 					FepUI()->HandleKeyL(aCode, aLength);
       
   970 					response = EKeyWasConsumed;
       
   971 					}
       
   972 				else
       
   973 					{
       
   974                	 	//PhraseCreation(EFalse);
       
   975             		response = HandleHashKeyL(aLength);
       
   976             		(aLength == ELongKeyPress)? SetLastPressedHashKeyStatus(EFalse):
       
   977                                         		SetLastPressedHashKeyStatus(ETrue);
       
   978 					}
       
   979 				}
       
   980      	     else if (InputMode()!= EZhuyin)
       
   981                 {
       
   982                 if (IsPinyinPhraseCreation() )
       
   983                     {
       
   984                     ClearCcpuFlag( ECcpuStateHashDown );
       
   985                     response = EKeyWasConsumed;
       
   986                     }
       
   987                 else
       
   988                     {
       
   989                     response = HandleHashKeyL(aLength);
       
   990                     (aLength == ELongKeyPress)
       
   991                         ? SetLastPressedHashKeyStatus(EFalse)
       
   992                             : SetLastPressedHashKeyStatus(ETrue);
       
   993                     }
       
   994                 }
       
   995             else
       
   996                 {
       
   997                 PhraseCreation(EFalse);
       
   998                 response = HandleHashKeyL(aLength);
       
   999                 (aLength == ELongKeyPress)
       
  1000                     ? SetLastPressedHashKeyStatus(EFalse)
       
  1001                         : SetLastPressedHashKeyStatus(ETrue);
       
  1002                 }
       
  1003             break;
       
  1004         case EKeyCBA1:
       
  1005             if(Japanese())
       
  1006                 {
       
  1007                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1008                     {
       
  1009                     response = EKeyWasConsumed;
       
  1010                     }
       
  1011                 break;
       
  1012                 }
       
  1013             // phrase creation the key CBA2 need to solve.
       
  1014             if ( IsEntryPhrase() )
       
  1015                 {
       
  1016                 if ( FepUI()->HandleKeyL( aCode, aLength ) )
       
  1017                     {
       
  1018                     response = EKeyWasConsumed;
       
  1019                     break;
       
  1020                     }
       
  1021                 }
       
  1022 
       
  1023             if (!WesternPredictive())
       
  1024                 {
       
  1025                 if (TryCloseUiL())
       
  1026                     {
       
  1027                     response = EKeyWasConsumed;
       
  1028                     }
       
  1029                 }            
       
  1030             break;
       
  1031         case EKeyCBA2:
       
  1032             if(Japanese())
       
  1033                 {
       
  1034                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1035                     {
       
  1036                     response = EKeyWasConsumed;
       
  1037                     }
       
  1038                 break;
       
  1039                 }
       
  1040             if (!WesternPredictive())
       
  1041                 {
       
  1042                 if (TryCloseUiL())
       
  1043                     {
       
  1044                     // phrase creation the key CBA2 need to solve.
       
  1045                     PhraseCreation( EFalse );
       
  1046                     response = EKeyWasConsumed;
       
  1047                     }
       
  1048                 }
       
  1049      		 else
       
  1050                 {
       
  1051                 if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  1052                     {
       
  1053                     InternalFepUI()->ExpireMultitapTimer();
       
  1054                     }
       
  1055                 }
       
  1056             // phrase creation the key CBA2 need to solve.
       
  1057             EntryPhrase( EFalse );
       
  1058             break;
       
  1059         case EPtiKeyStar:
       
  1060             if (IsFlagSet(EFlagPassNextKey))
       
  1061                 {
       
  1062                 ClearFlag(EFlagPassNextKey);
       
  1063                 }
       
  1064             else if ( !IsFepAwareTextEditor() )
       
  1065                 {
       
  1066                 // The editor is MFNE or other non FEP aware text editor.
       
  1067                 // Pass the key to the editor to handle.
       
  1068                 response = EKeyWasNotConsumed;
       
  1069                 }
       
  1070             else if (IsFlagSet(EFlagShiftKeyDepressed))
       
  1071                 {
       
  1072                 response = EKeyWasConsumed;
       
  1073                 }
       
  1074             else 
       
  1075                 {
       
  1076 #ifdef RD_SCALABLE_UI_V2                
       
  1077                 iStarKeyPressed = ETrue;
       
  1078 #endif // RD_SCALABLE_UI_V2                    
       
  1079                 if (FepUI()->HandleKeyL(aCode, aLength, aEventCode))
       
  1080                     {
       
  1081                     response = EKeyWasConsumed;
       
  1082                     }
       
  1083 #ifdef RD_SCALABLE_UI_V2                
       
  1084                 iStarKeyPressed = EFalse;
       
  1085 #endif // RD_SCALABLE_UI_V2                     
       
  1086                 }
       
  1087             break;
       
  1088         case EKeyRightArrow:
       
  1089             if (TryHandleArrowRightEventL(documentLength))
       
  1090                 {
       
  1091                 response = EKeyWasConsumed;
       
  1092                 break;
       
  1093                 }
       
  1094             // fall through
       
  1095         case EKeyLeftArrow:
       
  1096             if (aCode == EKeyLeftArrow && TryHandleArrowLeftEventL(documentLength))
       
  1097                 {
       
  1098                 response = EKeyWasConsumed;
       
  1099                 break;
       
  1100                 }
       
  1101                 
       
  1102             if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))    
       
  1103                 {
       
  1104                 response = EKeyWasNotConsumed;
       
  1105                 break;
       
  1106                 }            
       
  1107             else if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateStartCut))    
       
  1108                 {
       
  1109                 TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);                
       
  1110                 break;
       
  1111                 }               
       
  1112 
       
  1113             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1114                 {
       
  1115                 if(FepUI()->HandleKeyL(aCode, aLength))
       
  1116                     {
       
  1117                     response = EKeyWasConsumed;
       
  1118                     }
       
  1119                 }
       
  1120             else
       
  1121                 {
       
  1122                 if (WesternPredictive())
       
  1123                     {
       
  1124                     response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1125                     }
       
  1126                 else
       
  1127                     {
       
  1128                     if (iFepManState == EAknFepStateUIActive)
       
  1129                         {
       
  1130                         FepUI()->HandleKeyL(aCode, aLength);
       
  1131                         response = EKeyWasConsumed;
       
  1132                         }
       
  1133                     else
       
  1134                         {
       
  1135                         /*
       
  1136 						TCursorSelection currentEditorSelection(0,0);
       
  1137 						if(iInputCapabilities.FepAwareTextEditor())
       
  1138 							{
       
  1139 							iInputCapabilities.FepAwareTextEditor()->
       
  1140 								GetCursorSelectionForFep(currentEditorSelection);
       
  1141 							}
       
  1142                         
       
  1143 						if(!IsMfneEditor() &&
       
  1144 								(PluginInputMode() == EPluginInputModeItut ||
       
  1145 								 PluginInputMode() == EPluginInputModeFSQ)  &&
       
  1146 								 currentEditorSelection.Length() != 0)
       
  1147 							{
       
  1148 							response = EKeyWasConsumed;
       
  1149 							break;
       
  1150 							}
       
  1151 						*/
       
  1152 
       
  1153                         response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
  1154                         if (response == EKeyWasConsumed)
       
  1155                             {
       
  1156                             iCaseMan->UpdateCase(ENullNaviEvent);
       
  1157                             }
       
  1158                         else if (aCode == EKeyLeftArrow && !IsFlagSet(EFlagShiftKeyDepressed))
       
  1159                             {
       
  1160                             iCaseMan->UpdateCase(ELeftNaviEvent);
       
  1161                             }
       
  1162                         else if (!IsFlagSet(EFlagShiftKeyDepressed))
       
  1163                             {
       
  1164                             iCaseMan->UpdateCase(ERightNaviEvent);
       
  1165                             }
       
  1166                         }
       
  1167                     }
       
  1168                 }
       
  1169             break;
       
  1170         case EKeyDownArrow:
       
  1171        	    if( iWesternPredictive && IsFlagSet(EFlagInsideInlineEditingTransaction) && 
       
  1172        	    	( EPtiKeyboard12Key == KeyboardLayout() ) && ( IsFlagSet(EFlagShiftKeyDepressed) ||
       
  1173        	    	  HashKeySelectionInUse()&& IsCcpuFlagSet(ECcpuStateHashDown) ) )
       
  1174             	{
       
  1175  				iPtiEngine->CommitCurrentWord();
       
  1176             	CommitInlineEditL();
       
  1177             	response = EKeyWasConsumed;
       
  1178             	break;
       
  1179             	}
       
  1180 
       
  1181           if (TryHandleArrowDownEventL(documentLength) || IsFlagSet(EFlagNoMatches))
       
  1182                 {
       
  1183                 response = EKeyWasConsumed;
       
  1184                 break;
       
  1185                 }
       
  1186                 
       
  1187         case EKeyUpArrow:
       
  1188             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1189                 {
       
  1190                 if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1191                     IsFlagSet(EFlagShiftKeyDepressed) )
       
  1192                     {
       
  1193                     // Up or down key is pressed during shift key press.
       
  1194                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1195                     return EKeyWasNotConsumed;
       
  1196                     }
       
  1197 
       
  1198                 if(FepUI()->HandleKeyL(aCode, aLength))
       
  1199                     {
       
  1200                     response = EKeyWasConsumed;
       
  1201                     }
       
  1202                 else
       
  1203                     {
       
  1204                     TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);
       
  1205                     }
       
  1206                 }
       
  1207             else
       
  1208                 {
       
  1209                 if (iLanguageCapabilities.iInputLanguageCode == ELangThai &&
       
  1210                     iFepManState == EAknFepStateUIActive &&
       
  1211                     WesternPredictive() )
       
  1212                     {
       
  1213                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1214                         {
       
  1215                         ClearFlag(EFlagChangeInputMode);
       
  1216                         response = EKeyWasConsumed;
       
  1217                         }
       
  1218                     break;
       
  1219                     }
       
  1220                 else if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1221                     IsFlagSet(EFlagShiftKeyDepressed) )
       
  1222                     {
       
  1223                     // Up or down key is pressed during shift key press.
       
  1224                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1225                     return EKeyWasNotConsumed;
       
  1226                     }
       
  1227                 if (WesternPredictive())
       
  1228                     {
       
  1229                     // For customizabal of Down/Up scroll keypress action.
       
  1230                     // If it need to custom it, the function of HandleKeyL returns EFalse.
       
  1231 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1232                     // Predictive QWERTY (XT9) changes ---->
       
  1233                     if ( IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
       
  1234                         {
       
  1235                         TInt wordIndexToSelect = 0;
       
  1236                         
       
  1237                         if(iQwertyInputMode && EPtiKeyboardHalfQwerty != KeyboardLayout())
       
  1238                         	{
       
  1239                         	if(!iPrimaryCandidate)
       
  1240                             iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  1241         							&wordIndexToSelect );
       
  1242                             
       
  1243                         	if( iQwertyInputMode 
       
  1244                         	    && ( iExactWordPopupContent->IsPopUpVisible() 
       
  1245                         	    	|| ( iFepPluginManager && iFepPluginManager->IsTooltipOpenOnFSQ() ) )
       
  1246                         	    && aCode == EKeyUpArrow )
       
  1247 	                        	{
       
  1248 		                        iExactWordPopupContent->HidePopUp();
       
  1249                             
       
  1250                                 // When press up, if FSQ is opened, 
       
  1251                                 // also need to check and close tooltip on it.
       
  1252 		                        SendEventsToPluginManL( EPluginHideTooltip );
       
  1253 		                                                                                    
       
  1254 	                        	iPtiEngine->HandleCommandL( 
       
  1255                                            EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  1256 	                        								 &wordIndexToSelect );
       
  1257 	                        	iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );
       
  1258 	                        	/* Update the Candidate List in case of Exact Typing as best predicted word is 
       
  1259 	                             selected from the tooltip to the editor */
       
  1260 	                        	if(!iPrimaryCandidate)
       
  1261 	                        	    iPtiEngine->HandleCommandL(EPtiCommandSetFlagToUpdateCandidates);
       
  1262 	                        	    
       
  1263 	                        	TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  1264 	                        	UpdateInlineEditL( selectedWord, selectedWord.Length() ); 
       
  1265 	                        	response = EKeyWasConsumed;
       
  1266 		                     
       
  1267 	                        	}
       
  1268 	                        else
       
  1269 	                        	{
       
  1270 		                        LaunchCandidatePopupListL( wordIndexToSelect );
       
  1271 		                        response = EKeyWasConsumed;
       
  1272 	                        	}
       
  1273                         	}
       
  1274                         else
       
  1275                         	{
       
  1276                         	if (!IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  1277                         	    {
       
  1278                         	    TInt lastCandidateIndex = iPtiEngine->NumberOfCandidates() -1;
       
  1279                            	    if( EPtiKeyboard12Key == KeyboardLayout() && ( IsFlagSet(EFlagShiftKeyDepressed) ||
       
  1280                            	    		  HashKeySelectionInUse()&& IsCcpuFlagSet(ECcpuStateHashDown) ) )
       
  1281     	                        	{
       
  1282     	                            if (response != EKeyWasConsumed)
       
  1283     	                                {
       
  1284     	                                response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1285     	                                }
       
  1286     	                        	}
       
  1287                            	    else if(aCode == EKeyUpArrow && lastCandidateIndex >= 0)
       
  1288                         	        {
       
  1289                         	        // Get last word on list
       
  1290                         	        LaunchCandidatePopupListL( lastCandidateIndex );
       
  1291                         	        response = EKeyWasConsumed;
       
  1292                         	        }
       
  1293                         	    else
       
  1294                         	        {
       
  1295                         	        // Get next word on list (wrap around if at end)
       
  1296                         	        iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, 
       
  1297             							&wordIndexToSelect );
       
  1298                         	        wordIndexToSelect < lastCandidateIndex ? wordIndexToSelect++ : wordIndexToSelect = 0;
       
  1299                         	        LaunchCandidatePopupListL( wordIndexToSelect );
       
  1300                         	        response = EKeyWasConsumed;
       
  1301                         	        }                        	                        	    
       
  1302                         	    }
       
  1303                         	else
       
  1304                         	    response = EKeyWasConsumed;
       
  1305                         	}
       
  1306                         }
       
  1307                     else
       
  1308                         {                       
       
  1309 	                    // Predictive QWERTY (XT9) changes <----
       
  1310 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1311                     if(iFepManState == EAknFepStateUIActive &&
       
  1312                         FepUI()->HandleKeyL(aCode, aLength))
       
  1313                         {
       
  1314                         response = EKeyWasConsumed;
       
  1315 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1316 
       
  1317                         // When press up, if FSQ is opened, 
       
  1318                         // also need to check and close tooltip on it.
       
  1319                         SendEventsToPluginManL( EPluginHideTooltip );
       
  1320 
       
  1321 	                    // Predictive QWERTY (XT9) changes ---->
       
  1322 	                    // Exact word popup is hidden when the exact word is selected
       
  1323 	                    iExactWordPopupContent->HidePopUp();
       
  1324 	                    // Predictive QWERTY (XT9) changes <----
       
  1325 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1326                         }
       
  1327                     // normal operation of  Down/Up scroll keypress action.
       
  1328                     if (response != EKeyWasConsumed)
       
  1329                         {
       
  1330                         response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1331                         }
       
  1332 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1333                         } // Predictive QWERTY (XT9) changes
       
  1334 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1335                     }
       
  1336                 else
       
  1337                     {
       
  1338                     if (iFepManState == EAknFepStateUIActive)
       
  1339                         {
       
  1340                         FepUI()->HandleKeyL(aCode, aLength);
       
  1341                         response = EKeyWasConsumed;
       
  1342                         }
       
  1343                     else
       
  1344                         {
       
  1345                         TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);
       
  1346                         }
       
  1347                     }
       
  1348                 }
       
  1349             break;
       
  1350         case EKeyBackspace:
       
  1351             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese &&
       
  1352                 !(iMode == ELatin || iMode == ENumber))
       
  1353                 {
       
  1354                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1355                     {
       
  1356                     response = EKeyWasConsumed;
       
  1357                     }
       
  1358                 }
       
  1359             else if (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
  1360                 {
       
  1361                 TCursorSelection cursorSelection;
       
  1362                 if ( !IsFepAwareTextEditor() )                                           
       
  1363                     {
       
  1364                     response = EKeyWasNotConsumed;
       
  1365                     }
       
  1366                 else
       
  1367                     {
       
  1368                     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  1369                     if (cursorSelection.Length() != 0)      
       
  1370                         {
       
  1371                         response = EKeyWasNotConsumed;
       
  1372                         }
       
  1373 #ifdef RD_SCALABLE_UI_V2
       
  1374                     else if ( !documentLength 
       
  1375                         && ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut
       
  1376                         || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb ) )
       
  1377                         {
       
  1378                         response = EKeyWasConsumed;
       
  1379                         }
       
  1380 #endif   
       
  1381 										else 
       
  1382                         {
       
  1383                         if (FepUI()->HandleKeyL(aCode, aLength))
       
  1384                             {
       
  1385                             response = EKeyWasConsumed;
       
  1386                             }
       
  1387                         else
       
  1388                             {
       
  1389                             if( WesternPredictive() )
       
  1390                                 {
       
  1391                                 // We need to start the autoconcatination timer
       
  1392                                 SimulateKeyEventL(EKeyF24);
       
  1393                                 }
       
  1394                             }
       
  1395                         }
       
  1396                     }
       
  1397                 
       
  1398                 }
       
  1399             else if (IsKoreanInputLanguage() && iMode == EHangul)
       
  1400                 {
       
  1401                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1402                     {
       
  1403                     response = EKeyWasConsumed;
       
  1404                     }
       
  1405                 }
       
  1406             else
       
  1407                 {
       
  1408                 if (iFepManState == EAknFepStateInitial)
       
  1409                     {
       
  1410 #ifdef RD_SCALABLE_UI_V2
       
  1411                      if ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut )
       
  1412                         {
       
  1413                         if ( iFepPluginManager->CurrentFepInputUI() && 
       
  1414                             FepUI()->HandleKeyL(aCode, aLength))
       
  1415                             {
       
  1416                             response = EKeyWasConsumed;
       
  1417                             break;
       
  1418                             }
       
  1419                         }
       
  1420                      if ( !documentLength 
       
  1421                         && ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut
       
  1422                         || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb ) )
       
  1423                         {
       
  1424                         response = EKeyWasConsumed;
       
  1425                         break;
       
  1426 
       
  1427                         }
       
  1428 #endif                        
       
  1429                     if (IsFlagSet(EFlagLineFeedCharacter))
       
  1430                         {
       
  1431                         // restore cursor visibility
       
  1432                         if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  1433                             {
       
  1434                             iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);        
       
  1435                             }
       
  1436                         
       
  1437                         iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  1438                         ClearFlag(EFlagInsideMultitapInlineEditingTransaction | 
       
  1439                                   EFlagInsideInlineEditingTransaction | 
       
  1440                                   EFlagLineFeedCharacter);
       
  1441                         response =  EKeyWasConsumed;
       
  1442                         }
       
  1443                     else
       
  1444                         {
       
  1445                         response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
  1446                         if (WesternPredictive() && response == EKeyWasNotConsumed)
       
  1447                             {
       
  1448                             // if we're passing a backspace to the editor simulate any old keypress
       
  1449                             // to catch and check the state of play after the deletion
       
  1450                             SimulateKeyEventL(EKeyF24);
       
  1451                             }
       
  1452                         if (response == EKeyWasNotConsumed)
       
  1453                             {
       
  1454                             if(iMode == EZhuyinFind)
       
  1455                                 {
       
  1456                                 SetFlag(EFlagSupressAutoUpdate);
       
  1457                                 }
       
  1458                             if (iLongClearAfterCloseUI &&
       
  1459                                 aLength == ELongKeyPress)
       
  1460                                 {
       
  1461                                 response = EKeyWasConsumed;
       
  1462                                 }
       
  1463 
       
  1464                             iCaseMan->UpdateCase(EBackspaceEvent);
       
  1465                             }
       
  1466 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1467                         if(IsAutoCompleteOn())
       
  1468                             {
       
  1469                             TInt tailLength = 0;
       
  1470                             iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
  1471                                                         &tailLength );
       
  1472                             if(tailLength > 0)
       
  1473                                 {
       
  1474                                 RemoveSuggestedAdvanceCompletionL();
       
  1475                                 }
       
  1476                             }
       
  1477 #endif
       
  1478                         }
       
  1479                     
       
  1480                     // Clear the star key flag.
       
  1481                     if( FepUI() )
       
  1482                         {
       
  1483                         FepUI()->SetStarKeyFlag( EFalse );
       
  1484                         }
       
  1485                     }
       
  1486 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1487                 else if (IsAutoCompleteOn())
       
  1488                     {
       
  1489                     TInt tailLength = 0;
       
  1490                     iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
  1491                                                 &tailLength );
       
  1492                     if(tailLength > 0)
       
  1493                         {
       
  1494                         TryRemoveNoMatchesIndicatorL();
       
  1495                         RemoveSuggestedAdvanceCompletionL();
       
  1496                         SimulateKeyEventL(EKeyF19);
       
  1497                         UpdateCbaL(NULL);
       
  1498                         response=EKeyWasConsumed;
       
  1499                         }
       
  1500                     else if(FepUI()->HandleKeyL(aCode, aLength))
       
  1501                         {
       
  1502                         if( EPtiKeyboardHalfQwerty == KeyboardLayout()
       
  1503                         		&& iWesternPredictive
       
  1504                         		&& iCaseMan->CurrentCase() != EAknEditorUpperCase )
       
  1505                             {
       
  1506                         	ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  1507                             }
       
  1508                         iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
  1509                         if(tailLength > 0)
       
  1510                             {
       
  1511                             RemoveSuggestedAdvanceCompletionL();
       
  1512                             }
       
  1513                         response = EKeyWasConsumed;
       
  1514                         }
       
  1515                     }
       
  1516                 else if(FepUI()->HandleKeyL(aCode, aLength))
       
  1517                     {
       
  1518                     response = EKeyWasConsumed;
       
  1519                     }
       
  1520                 SendEventsToPluginManL( EPluginHideTooltip );
       
  1521                 if(iExactWordPopupContent && iExactWordPopupContent->IsPopUpVisible())
       
  1522                     {
       
  1523                     iExactWordPopupContent->HidePopUp();
       
  1524                     }               
       
  1525 #else
       
  1526                 else if (FepUI()->HandleKeyL(aCode, aLength))
       
  1527                     {
       
  1528                     response = EKeyWasConsumed;
       
  1529                     }                
       
  1530 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1531                 }
       
  1532             break;
       
  1533         case EKeyDelete:
       
  1534 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1535 			if(IsAutoCompleteOn())
       
  1536 				{
       
  1537 				TInt tailLength = 0;
       
  1538 				iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
  1539 												&tailLength );
       
  1540 				if(tailLength > 0)
       
  1541 					{
       
  1542 					RemoveSuggestedAdvanceCompletionL();
       
  1543 				    }
       
  1544 				}
       
  1545 
       
  1546             // When press delete key, if FSQ is opened, 
       
  1547             // also need to check and close tooltip on it.
       
  1548 			SendEventsToPluginManL( EPluginHideTooltip );
       
  1549 
       
  1550 			if(iExactWordPopupContent && iExactWordPopupContent->IsPopUpVisible())
       
  1551 				{
       
  1552 		        iExactWordPopupContent->HidePopUp();
       
  1553 				}
       
  1554         	if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  1555             	{
       
  1556             	TryRemoveNoMatchesIndicatorL();
       
  1557             	UpdateCbaL(NULL);
       
  1558             	CommitInlineEditL();
       
  1559     	        } 
       
  1560 #endif //RD_INTELLIGENT_TEXT_INPUT        
       
  1561         	break;            
       
  1562         case EKeyF19:  // Fep simulated event to asynchronously update the case.
       
  1563             iCaseMan->UpdateCase(ENullNaviEvent);
       
  1564             response=EKeyWasConsumed;
       
  1565             ClearExtendedFlag(EExtendedFlagOkKeyPressOnCandidatePopup );
       
  1566             break;
       
  1567         case EKeyF22:
       
  1568             if (WesternPredictive())
       
  1569                 {
       
  1570                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  1571                 if (CursorInsideWord())
       
  1572                     {
       
  1573                     MoveCursorToEndOfWordL();
       
  1574                     }
       
  1575                 if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
  1576                     {
       
  1577                     iCaseMan->UpdateCase(ENullNaviEvent);
       
  1578                     }
       
  1579                 }
       
  1580             else if (iMode == ELatin)
       
  1581                 {
       
  1582                 iCaseMan->UpdateCase(ENullNaviEvent);
       
  1583                 }
       
  1584             ClearCcpuFlag(ECcpuStateIgnoreStarUp);    
       
  1585             response=EKeyWasConsumed;
       
  1586             break;
       
  1587         case EKeyF23:
       
  1588             if (WesternPredictive())
       
  1589                 {
       
  1590                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  1591                 if (CursorInsideWord())
       
  1592                     {
       
  1593                     MoveCursorToStartOfWordL();
       
  1594                     }
       
  1595                 if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
  1596                     {
       
  1597                     iCaseMan->UpdateCase(ENullNaviEvent);
       
  1598                     }
       
  1599                 }
       
  1600             else if (iMode == ELatin)
       
  1601                 {
       
  1602                 iCaseMan->UpdateCase(ENullNaviEvent);
       
  1603                 }
       
  1604             ClearCcpuFlag(ECcpuStateIgnoreStarUp);    
       
  1605             response=EKeyWasConsumed;
       
  1606             break;
       
  1607         case EKeyF24:
       
  1608             if (WesternPredictive() && CursorInsideWord())
       
  1609                 {
       
  1610                 // word concatenation - start the timer; add concatenated word
       
  1611                 // to UDB on timer expiry
       
  1612                 iConcatenationTimer->Start(EWordConcatenationTimeout, EWordConcatenationTimeout,
       
  1613                     TCallBack(WordConcatenationTimerTimeoutCallback, this));
       
  1614                 }
       
  1615             response=EKeyWasConsumed;
       
  1616             break;
       
  1617         case EPtiKey0: //fall through
       
  1618         case EPtiKey1:
       
  1619         case EPtiKey2:
       
  1620         case EPtiKey3:
       
  1621         case EPtiKey4:
       
  1622         case EPtiKey5:
       
  1623         case EPtiKey6:
       
  1624         case EPtiKey7:
       
  1625         case EPtiKey8:
       
  1626         case EPtiKey9:
       
  1627             #ifdef RD_SCALABLE_UI_V2     
       
  1628                 if ( aLength == ELongKeyPress && !isPassNext && (aCode == EPtiKey0) )
       
  1629                     {
       
  1630                     if( !IsQwerty() && 
       
  1631                         !IsFlagSet(CAknFepManager::EFlagPassNextKey)&&
       
  1632                         iFepPluginManager->PluginInputMode() != EPluginInputModeItut )
       
  1633                         {
       
  1634                         iFepPluginManager->ClosePluginInputModeL( ETrue );
       
  1635                         }
       
  1636                     }
       
  1637             #endif
       
  1638              if (IsFlagSet(EFlagLineFeedCharacter) && aCode != EPtiKey0)
       
  1639                 {
       
  1640                 // There is line feed character waiting. Pospone this event and handle
       
  1641                 // line feed first.
       
  1642                 CancelInlineEdit();
       
  1643                  if (!(iAknEditorFlags & EAknEditorFlagFindPane) || iQwertyInputMode)
       
  1644                  {
       
  1645                   SimulateKeyEventL(EKeyEnter);
       
  1646                   SimulateKeyEventL(EKeyF19); // Asyncronous case update    
       
  1647                  }
       
  1648                 SimulateKeyEventL((TPtiKey)aCode);                  
       
  1649                 ClearFlag(EFlagLineFeedCharacter);
       
  1650                 return EKeyWasConsumed;                 
       
  1651                 }                
       
  1652             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1653                 {
       
  1654                 if (EditorHasFreeSpace() || iFepManState == EAknFepStateUIActive)
       
  1655                     {
       
  1656                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1657                         {
       
  1658                         ClearFlag(EFlagChangeInputMode);
       
  1659                         response = EKeyWasConsumed;
       
  1660                         }
       
  1661                     // response is EKeyWasNotConsumed
       
  1662                     }
       
  1663                 }
       
  1664             else
       
  1665                 {
       
  1666                 //pass extra key received when doing secret text edit
       
  1667                 if (IsFlagSet(EFlagPassNextKey))
       
  1668                     {
       
  1669                     ClearFlag(EFlagPassNextKey);
       
  1670                     }
       
  1671                 else if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
  1672                     {
       
  1673                     response = EKeyWasConsumed;
       
  1674                     }
       
  1675                     
       
  1676                 // The key event is passed to the editor to handle in case of
       
  1677                 // MFNE and other non FEP aware editors (response = EKeyWasNotConsumed).
       
  1678                 else if ( IsFepAwareTextEditor() )
       
  1679                     {
       
  1680                     if ( ( iMode != ENumber && iMode != ENativeNumber ) ||
       
  1681                         ( ( iMode == ENumber || iMode == ENativeNumber )  && aLength == ELongKeyPress))
       
  1682                         {
       
  1683                         // Be default the key event is handled by FEP for FEP aware editors.
       
  1684                         response = EKeyWasConsumed;
       
  1685                         }
       
  1686 
       
  1687                     // New character can be entered to the editor if there is
       
  1688                     // space left in the editor. Editor can be modified also
       
  1689                     // is the last character is multitapped or last character
       
  1690                     // in inline state is replaced with a digit.
       
  1691                     /*Hindi*/
       
  1692                     //This condition is added for Hindi language in case of multitapping of EKey1 to get 
       
  1693                     //a numeral value "1" because of a clasical case of Halant and ZWS getting added 
       
  1694                     //before numeral 1 which may affect incase of limited space in editor   
       
  1695                         
       
  1696                     if (( EditorHasFreeSpace()
       
  1697                         || (!WesternPredictive() && !EditorHasFreeSpace() && 
       
  1698                            (TAknFepUiIndicInputManager::IsIndicLangauge(
       
  1699                             TLanguage(iLanguageCapabilities.iInputLanguageCode)))) 
       
  1700                         || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction)
       
  1701                         || (IsFlagSet(EFlagInsideInlineEditingTransaction) && aLength == ELongKeyPress)))
       
  1702                         {
       
  1703                         ClearFlag(EFlagEditorFull);
       
  1704 
       
  1705                         if (aLength == ELongKeyPress && 
       
  1706                            (iMode != ELatin && iMode != ENumber && iMode != ENativeNumber && iMode != EStrokeFind && iMode != EHangul) &&
       
  1707                             FepUI()->IsValidNumericLongKeyPress(aCode))
       
  1708                             {
       
  1709                             if (iFepManState == EAknFepStateInitial) // Multitapping
       
  1710                                 {
       
  1711 #ifdef RD_SCALABLE_UI_V2
       
  1712                                  if (iFepFullyConstructed && 
       
  1713                                      iFepPluginManager->CurrentFepInputUI() )
       
  1714                                      {
       
  1715                                      if (iFepPluginManager->CurrentFepInputUI()->HandleKeyL(aCode, 
       
  1716                                                                                          aLength))
       
  1717                                          {
       
  1718                                          response = EKeyWasConsumed;
       
  1719                                          break;
       
  1720                                          }
       
  1721                                      }
       
  1722 #endif        
       
  1723                                 // Current multitabbed character is replaced with a number.
       
  1724                                 TChar ch(aCode);
       
  1725                                 TBuf<1> buf;
       
  1726                                 buf.Append(ch);
       
  1727                                 NewCharacterL(buf);
       
  1728                                 CommitInlineEditL();
       
  1729                                 iPtiEngine->ClearCurrentWord();
       
  1730                                 }
       
  1731                             else
       
  1732                                 {
       
  1733                                 // Long number key press is given to the editor.
       
  1734                                 TryCloseUiL();
       
  1735                                 response = EKeyWasNotConsumed;
       
  1736                                 }
       
  1737                             }
       
  1738                         else if (FepUI()->HandleKeyL(aCode, aLength))
       
  1739                             {
       
  1740         	            	if ( (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie)
       
  1741         	            			&& iFepManState == EAknFepStateUIActive )
       
  1742         	            		{
       
  1743         	            		if ( EditorState() )
       
  1744         	            			{
       
  1745         	            			EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagChinesePopup );
       
  1746         	            			}       	            		
       
  1747         	            		}
       
  1748                             ClearFlag(EFlagChangeInputMode);
       
  1749                             // for japanese variant
       
  1750                             if (IsFeatureSupportedJapanese()
       
  1751                              && iMode == ENumber)
       
  1752                                 {
       
  1753                                 response = EKeyWasConsumed;
       
  1754                                 }
       
  1755                             }
       
  1756                         else
       
  1757                             {
       
  1758                             //By default, pass long keypress to an editor for inserting number.
       
  1759                             response = EKeyWasNotConsumed;
       
  1760                             //No need to handle long key press in dialer
       
  1761                             if ( RProcess().SecureId().iId != KPhoneSecureId )
       
  1762                                 {
       
  1763 
       
  1764                                 if ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  1765                                     {
       
  1766                                     SimulateKeyEventL( aCode + KLatinToArabicIndicDigitsDelta );
       
  1767                                     response = EKeyWasConsumed;
       
  1768                                     }
       
  1769                                 else if( iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )    
       
  1770                                     {
       
  1771                                     SimulateKeyEventL( aCode + KLatinToEasternArabicIndicDigitsDelta );
       
  1772                                     response = EKeyWasConsumed;
       
  1773                                     }
       
  1774                                 /*Hindi*/    
       
  1775                                 else if ( iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari 
       
  1776                                             || iPreviousEditingState == EDevanagariIndicNumeric )                           
       
  1777                                     {
       
  1778                                     
       
  1779                                     SimulateKeyEventL( aCode + KLatinToDevanagariDigitsDelta );
       
  1780                                     
       
  1781                                     response = EKeyWasConsumed;
       
  1782                                     }
       
  1783                                 }
       
  1784                             }
       
  1785                         }
       
  1786                     }                   
       
  1787                 }
       
  1788             break;
       
  1789         case EKeyOK:
       
  1790             {
       
  1791             if (iUiInterface->SoftkeysExist() && EditSubmenuInUse()) 
       
  1792                 {                           
       
  1793                 if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EAknFepSoftkeyStartCopy)
       
  1794                     {                                     
       
  1795                     ProcessCommandL(EAknFepSoftkeyStartCopy);
       
  1796                     response = EKeyWasConsumed;             
       
  1797                     break;
       
  1798                     }
       
  1799                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EAknFepSoftkeyStartCut)
       
  1800                     {
       
  1801                     ProcessCommandL(EAknFepSoftkeyStartCut);
       
  1802                     response = EKeyWasConsumed;             
       
  1803                     break;              
       
  1804                     }
       
  1805                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EEikCmdEditCopy)
       
  1806                     {                                     
       
  1807                     ProcessCommandL(EEikCmdEditCopy);
       
  1808                     response = EKeyWasConsumed;             
       
  1809                     break;
       
  1810                     }
       
  1811                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EEikCmdEditCut)
       
  1812                     {
       
  1813                     ProcessCommandL(EEikCmdEditCut);
       
  1814                     response = EKeyWasConsumed;             
       
  1815                     break;              
       
  1816                     }                                                                               
       
  1817                 }
       
  1818             
       
  1819             if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1820                 IsFlagSet(EFlagShiftKeyDepressed) )
       
  1821                 {
       
  1822                 // Selection key is pressed during shift key press.
       
  1823                 ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1824                 return EKeyWasNotConsumed;
       
  1825                 }
       
  1826             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1827                 {
       
  1828                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1829                     {
       
  1830                     response = EKeyWasConsumed;
       
  1831                     }
       
  1832                 }
       
  1833             else
       
  1834                 {
       
  1835                 if (IsFlagSet(EFlagShiftKeyDepressed) && 
       
  1836                   !(iAknEditorFlags & EAknEditorFlagSupressShiftMenu))
       
  1837                     {
       
  1838                     response = EKeyWasConsumed;
       
  1839                     }
       
  1840                 else if (iFepManState == EAknFepStateUIActive)
       
  1841                     {
       
  1842                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1843                         {
       
  1844                         response = EKeyWasConsumed;
       
  1845                         }
       
  1846                     }
       
  1847                 else if (iMode == ELatin && !WesternPredictive() && 
       
  1848                          IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))                    
       
  1849                     {
       
  1850                     CommitInlineEditL();
       
  1851                     }
       
  1852 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1853 			    // Predictive QWERTY (XT9) changes ---->
       
  1854 			    // Accept current candidate (including possible auto-completed part) and insert space after the word
       
  1855 			    // if selection key pressed while inline editing (on Qwerty only!)
       
  1856 			    // this is not the expected behavior for half qwerty
       
  1857 			    
       
  1858 				TBool isQwertyMode = iQwertyInputMode && 
       
  1859 								!( EPtiKeyboardHalfQwerty == KeyboardLayout() );
       
  1860 			    if ( response == EKeyWasNotConsumed && iWesternPredictive && isQwertyMode && 
       
  1861 			         IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
  1862 			         // For addition of ITI features on FSQ. 
       
  1863 			         // If FSQ is opened with ITI features activated, don't commit as HW's action
       
  1864 			         && !( iFepPluginManager && iFepPluginManager->EnableITIOnFSQ() ) )
       
  1865 			        {
       
  1866 			        
       
  1867 					// If the primary candidate setting is exact typing, The tooltip/bubble always shows the best prediction.
       
  1868 				    // Word on the typing line is accepted into editor on selection key event..  
       
  1869 					                  
       
  1870 			        iPtiEngine->CommitCurrentWord();
       
  1871 			        CommitInlineEditL();
       
  1872                     TryCloseUiL();
       
  1873                     if(!static_cast<TChar>(NextChar()).IsSpace())
       
  1874 	                    {
       
  1875 	                    SimulateKeyEventL(EKeySpace);
       
  1876 	                    }
       
  1877                     else 
       
  1878 	                	{
       
  1879 						TCursorSelection sel;
       
  1880             			iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(sel);
       
  1881             			sel.iCursorPos++;
       
  1882             			sel.iAnchorPos++;
       
  1883             			iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);	                		
       
  1884 	                	}    
       
  1885                     SimulateKeyEventL(EKeyF19); // asynchronous case update
       
  1886                 
       
  1887 			        response = EKeyWasConsumed;
       
  1888 			        }
       
  1889 			    // Predictive QWERTY (XT9) changes <----
       
  1890 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1891                 }
       
  1892             }
       
  1893             break;
       
  1894 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1895         	case EKeyPhoneEnd:
       
  1896 	        	{
       
  1897 	        	// Suggested word should get committed in exact typing
       
  1898 				if ( iWesternPredictive &&
       
  1899 			    	 IsFlagSet(EFlagInsideInlineEditingTransaction) )
       
  1900 			        {
       
  1901 						
       
  1902 					// If the primary candidate setting is exact typing, The tooltip/bubble always shows the best prediction.
       
  1903 					// Word on the typing line is accepted into editor on end key event..
       
  1904 						
       
  1905 			        iPtiEngine->CommitCurrentWord();
       
  1906 					CommitInlineEditL();
       
  1907 	            	TryCloseUiL();
       
  1908 	            	ClearFlag(CAknFepManager::EFlagNoMatches);
       
  1909 	            	SimulateKeyEventL(EKeyF19); // asynchronous case update
       
  1910 			        }
       
  1911 	        	}
       
  1912 			break;
       
  1913 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1914         default:
       
  1915             break;
       
  1916         }
       
  1917     SchedulePostEventCheckL(aCode);
       
  1918 
       
  1919 #ifdef RD_SCALABLE_UI_V2     
       
  1920     if ( !isPassNext )
       
  1921         {
       
  1922         SendEventsToPluginManL( EPluginKeyEvent, aCode );
       
  1923         }
       
  1924 #endif
       
  1925         
       
  1926     return response;
       
  1927     }
       
  1928     
       
  1929 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1930 void CAknFepManager::HandleShiftHalfQwertyChineseL(TEventCode aEventCode)
       
  1931     {
       
  1932     if (aEventCode == EEventKeyDown)
       
  1933         {
       
  1934         ClearCcpuFlag(ECcpuStateCbaShown);		
       
  1935         SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  1936         ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  1937         SetFlag(EFlagQwertyShiftMode);
       
  1938         // Long press of shift key timer is activated.
       
  1939         iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay,
       
  1940             EShiftKeyRepeatDelay, TCallBack(ResetShiftKeyMonitorCallback,
       
  1941                 this) );
       
  1942         }
       
  1943     else if (aEventCode == EEventKeyUp)
       
  1944         {
       
  1945         ClearFlag(EFlagShiftKeyDepressed
       
  1946             |EFlagNoActionDuringShiftKeyPress);
       
  1947         ClearFlag(EFlagQwertyShiftMode);
       
  1948         iShiftKeypressMonitor->Cancel();
       
  1949 
       
  1950         if ( (iKeyPressedDuringShift)|| IsFlagSet(EFlagLongShiftKeyPress) )
       
  1951             {
       
  1952             iKeyPressedDuringShift = EFalse;
       
  1953             ClearFlag( EFlagLongShiftKeyPress );
       
  1954             if ( iFnKeyManager->FnKeyState() )
       
  1955                 {
       
  1956                 iFnKeyManager->SetFnKeyState( CAknFepFnKeyManager::EFnKeyNone );
       
  1957                 }
       
  1958             UpdateIndicators();
       
  1959             }
       
  1960         else
       
  1961             {
       
  1962             CAknEdwinState* editorState = EditorState();
       
  1963             TInt permittedCases = editorState->PermittedCases();
       
  1964             permittedCases = permittedCases == 0 ?
       
  1965             EAknEditorLowerCase | EAknEditorUpperCase : permittedCases;
       
  1966 
       
  1967             if (iMode == ELatin && (permittedCases & EAknEditorTextCase))
       
  1968                 {
       
  1969                 // Latin case update is changed back to automatic if latin 
       
  1970                 // text case is allowed and the case is changed manually from #-key.
       
  1971                 ClearFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
  1972                 }
       
  1973             TInt currentCase = iCaseMan->CurrentCase();
       
  1974 
       
  1975             // Is current latin case last available case.
       
  1976             TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase)
       
  1977                     && ((currentCase == EAknEditorLowerCase)
       
  1978                         || (currentCase == EAknEditorUpperCase
       
  1979                             && !(permittedCases
       
  1980                                 & EAknEditorLowerCase)) )
       
  1981                     || (editorState->Flags() & EAknEditorFlagFixedCase) )
       
  1982                 || (editorState->Flags()
       
  1983                     & EAknEditorFlagForceTransparentFepModes) );
       
  1984 
       
  1985             if (iMode == ELatin
       
  1986                 && !IsFlagSet(CAknFepManager::EFlagChangeInputMode)
       
  1987                 && !lastCase)
       
  1988                 {
       
  1989                 if (iWesternPredictive)
       
  1990                     {
       
  1991                     // Input mode is still Latin. Only case is updated.
       
  1992                     if (permittedCases & EAknEditorTextCase)
       
  1993                         {
       
  1994                         iCaseMan->ManualCaseUpdate();
       
  1995                         }
       
  1996                     else
       
  1997                         {
       
  1998                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  1999                         }
       
  2000                     }
       
  2001                 else
       
  2002                     {
       
  2003                     if(iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  2004                         {
       
  2005                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2006                         }
       
  2007                     else
       
  2008                         {
       
  2009                         iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  2010                         }
       
  2011                     }
       
  2012 
       
  2013                 // Next time input mode is changed if any text is not entered before.
       
  2014                 SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2015                 }
       
  2016             else
       
  2017                 {
       
  2018                 // Input mode is incremented.
       
  2019                 SetChangeModeByShiftAndSpace( EFalse );
       
  2020                 TryIncrementChineseModeForQwertyL(iMode);
       
  2021 
       
  2022                 ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  2023 
       
  2024                 if ( iMode == ELatin && iWesternPredictive ) // New mode after Increment.
       
  2025 
       
  2026                     {
       
  2027                     if (editorState->Flags() & EAknEditorFlagFixedCase)
       
  2028                         {
       
  2029                         // Only one fixed case is available. Use it.
       
  2030                         iCaseMan->ConfigureCaseStateFromEditorState();
       
  2031                         SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2032                         }
       
  2033                     else if (editorState->Flags()
       
  2034                         & EAknEditorFlagForceTransparentFepModes)
       
  2035                         {
       
  2036                         // Only lower case is used with find pane.
       
  2037                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2038                         SetFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
  2039                         SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2040                         }
       
  2041                     else if (permittedCases & EAknEditorTextCase)
       
  2042                         {
       
  2043                         iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  2044                         iCaseMan->UpdateCase(ENullNaviEvent);
       
  2045                         }
       
  2046                     else
       
  2047                         {
       
  2048                         if (permittedCases & EAknEditorUpperCase)
       
  2049                             {
       
  2050                             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  2051                             if ( !(permittedCases
       
  2052                                     & EAknEditorLowerCase))
       
  2053                                 {
       
  2054                                 // We need to move to next input mode since only upper case 
       
  2055                                 // is permitted in Latin input mode.
       
  2056                                 SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2057                                 }
       
  2058                             }
       
  2059                         else
       
  2060                             {
       
  2061                             iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2062                             SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2063                             }
       
  2064                         }
       
  2065                     }
       
  2066                 }
       
  2067             }
       
  2068         }
       
  2069     }
       
  2070 
       
  2071 void CAknFepManager::HandleShiftQwertyChineseL(TEventCode aEventCode)
       
  2072     {
       
  2073     if ( IsFlagSet( EFlagQwertyChrKeyDepressed ) && 
       
  2074     	 !IsFeatureSupportedJapanese() && 
       
  2075     	 iCurrentFepUI->IsValidShiftKeyPress())
       
  2076     	{
       
  2077         ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2078         LaunchLanguagesPopupListL();
       
  2079         return;
       
  2080     	}
       
  2081     
       
  2082     TInt language = iSharedDataInterface->InputTextLanguage();
       
  2083 
       
  2084     if (aEventCode == EEventKeyUp)
       
  2085         {
       
  2086         ClearCcpuFlag(ECcpuStateCbaShown);
       
  2087         if (FepUI())
       
  2088             {
       
  2089             FepUI()->HandleKeyL(EKeyLeftShift, EShortKeyPress);
       
  2090             }
       
  2091         TBool validShift = iCurrentFepUI->IsValidShiftKeyPress();
       
  2092                 
       
  2093         if (IsFlagSet(EFlagLongShiftKeyPress) ||iKeyPressedDuringShift)
       
  2094             {
       
  2095             if (iKeyPressedDuringShift || IsFlagSet(EFlagQwertyShiftMode))
       
  2096                 {
       
  2097                 iShiftKeypressMonitor->Cancel();
       
  2098                 iKeyPressedDuringShift = EFalse;
       
  2099                 ClearFlag(EFlagQwertyShiftMode);
       
  2100                 }
       
  2101             }
       
  2102         else
       
  2103             if (IsFlagSet(EFlagQwertyShiftMode))
       
  2104                 {
       
  2105                 if ( iMode != ELatin && validShift )
       
  2106                     {
       
  2107                     iModeBefore = iMode;
       
  2108                     TryChangeModeL(ELatin);
       
  2109                     ClearFlag( EFlagQwertyShiftMode );
       
  2110                     }
       
  2111                 }
       
  2112             else
       
  2113                 {
       
  2114                 if (iMode == ELatin)
       
  2115                     {
       
  2116                     TBool isWsPr= EFalse;
       
  2117                     if (WesternPredictive())
       
  2118                         {
       
  2119                         SetWesternPredictive(EFalse);
       
  2120                         isWsPr = ETrue;
       
  2121                         }
       
  2122                     TInt Modetemp = iModeBefore;
       
  2123                     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
  2124                     if (Modetemp == EStroke && 
       
  2125                     	iQwertyInputMode && 
       
  2126                     	sharedDataMode == ECangJie)
       
  2127                     	{
       
  2128                     	Modetemp = ECangJie;
       
  2129                     	}
       
  2130 
       
  2131                     TryChangeModeL(Modetemp);
       
  2132                     if (isWsPr)
       
  2133                         {
       
  2134                         SetWesternPredictive(ETrue);
       
  2135                         }
       
  2136                     }
       
  2137                 }
       
  2138 
       
  2139         ClearFlag(EFlagShiftKeyDepressed);
       
  2140 
       
  2141         if (IsFlagSet(EFlagLongShiftKeyPress)
       
  2142                 && iMode == ELatin
       
  2143                 && IsFlagSet(EFlagQwertyShiftMode))//latin shift ->abc
       
  2144             {
       
  2145             ClearFlag(EFlagQwertyShiftMode);
       
  2146             }
       
  2147 
       
  2148         if (IsFlagSet(EFlagLongShiftKeyPress)) //long keypress up
       
  2149             {
       
  2150             ClearFlag(EFlagLongShiftKeyPress
       
  2151                     |EFlagNoActionDuringShiftKeyPress);
       
  2152             }
       
  2153         else // short keypress up
       
  2154             {
       
  2155             iShiftKeypressMonitor->Cancel();
       
  2156             }
       
  2157 
       
  2158         ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2159         ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  2160         if ( validShift )
       
  2161             {
       
  2162             UpdateIndicators();
       
  2163             }
       
  2164         else
       
  2165             {
       
  2166             ClearFlag(EFlagQwertyShiftMode);
       
  2167             }
       
  2168         }
       
  2169     else
       
  2170         if (aEventCode == EEventKeyDown)
       
  2171             {
       
  2172 
       
  2173             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2174             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2175 
       
  2176             if (IsFlagSet(EFlagQwertyShiftMode))
       
  2177                 {
       
  2178                 ClearFlag(EFlagQwertyShiftMode);
       
  2179                 }
       
  2180             else
       
  2181                 {
       
  2182                 SetFlag(EFlagQwertyShiftMode);
       
  2183                 if ( iCurrentFepUI->IsValidShiftKeyPress() 
       
  2184                 		|| iMode == ELatin )
       
  2185                     {
       
  2186                     UpdateIndicators();
       
  2187                     }
       
  2188    	            // If the iShiftKeypressMonitor is actived now, cancel it first.
       
  2189 	              iShiftKeypressMonitor->Cancel();
       
  2190                 // Long press of shift key timer is activated.
       
  2191                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay,
       
  2192                         EShiftKeyRepeatDelay, TCallBack(
       
  2193                                 ResetShiftKeyMonitorCallback, this));
       
  2194                 }
       
  2195             }
       
  2196     }
       
  2197 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2198 TKeyResponse CAknFepManager::HandleShiftKeyEventL(TEventCode aEventCode)
       
  2199     {
       
  2200     TKeyResponse response = EKeyWasNotConsumed;
       
  2201 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2202 	// GQF clarification 
       
  2203 	// In case irrespective Fn/shift key Text case should not be changed.
       
  2204 	// Like Shift +Fn + Shift should not toggle the text case of the editor.
       
  2205 	// Only Consecutive press of shift key should change the text case
       
  2206 	if( iQwertyInputMode && (EEventKeyDown== aEventCode) && EPtiKeyboardHalfQwerty != KeyboardLayout())
       
  2207 		{
       
  2208 		if( (iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNext) && 
       
  2209 			IsFlagSet(EFlagQwertyShiftMode))
       
  2210 			{
       
  2211 			iFnKeyManager->ClearFnKeyState();
       
  2212 			iPtiEngine->SetCase((TPtiTextCase)EPtiCaseLower);
       
  2213 			ClearFlag(EFlagQwertyShiftMode);
       
  2214 			}
       
  2215 		}
       
  2216     TInt language = iSharedDataInterface->InputTextLanguage();
       
  2217 #endif    
       
  2218     
       
  2219     if (iQwertyInputMode)
       
  2220         {
       
  2221         if ( !iInputCapabilities.FepAwareTextEditor() )
       
  2222             {
       
  2223             response = EKeyWasNotConsumed;
       
  2224             }
       
  2225 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2226         else if (language == ELangTaiwanChinese||
       
  2227                     language == ELangHongKongChinese ||
       
  2228                     language == ELangPrcChinese)
       
  2229                 {
       
  2230                 if ( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2231                         iPtiEngine &&
       
  2232                         ( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() ) &&
       
  2233                         ( aEventCode == EEventKeyDown || aEventCode == EEventKeyUp ) )
       
  2234                     {
       
  2235                     // Ignore the KeyUp event
       
  2236                     if( aEventCode == EEventKeyDown )
       
  2237                         {
       
  2238                         FepUI()->HandleKeyL( EPtiKeyQwertyLeftShift, 
       
  2239                                                      EShortKeyPress );
       
  2240                         }
       
  2241                     if( aEventCode == EEventKeyUp )
       
  2242                         {
       
  2243 			            ClearCcpuFlag(ECcpuStateCbaShown);
       
  2244                         }						
       
  2245                     }
       
  2246                 else
       
  2247                     {
       
  2248                     if ((iAknEditorFlags & EAknEditorFlagFindPane)&& (CAknFepFnKeyManager::EFnKeyNone ==FnKeyState()))
       
  2249                         {
       
  2250                         if (aEventCode == EEventKeyUp)
       
  2251                             {
       
  2252 				            ClearCcpuFlag(ECcpuStateCbaShown);							
       
  2253                             if ( iKeyPressedDuringShift )
       
  2254                                 {
       
  2255                                 iKeyPressedDuringShift = EFalse;
       
  2256                                 }
       
  2257                             else
       
  2258                                 {
       
  2259                                 TryIncrementModeChineseQwertyL( iMode );
       
  2260                                 }
       
  2261                             ClearFlag( EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress );
       
  2262                             }
       
  2263                         else if(aEventCode == EEventKeyDown)
       
  2264                             {
       
  2265                             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2266                             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2267                             }
       
  2268                         return EKeyWasConsumed;
       
  2269                         }
       
  2270                     if (EPtiKeyboardHalfQwerty == KeyboardLayout())
       
  2271                         {
       
  2272                         HandleShiftHalfQwertyChineseL(aEventCode);
       
  2273                         }
       
  2274                     else
       
  2275                         {
       
  2276                         HandleShiftQwertyChineseL(aEventCode);
       
  2277                         }
       
  2278                     }
       
  2279                 }
       
  2280 #endif // ITI flag
       
  2281         else if (aEventCode == EEventKeyDown)
       
  2282             {
       
  2283 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2284 #ifdef __HALF_QWERTY_KEYPAD
       
  2285             if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2286                 iPtiEngine && EditorHasFreeSpace())
       
  2287                 {
       
  2288 		if (IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
  2289                             {
       
  2290                             iPtiEngine->CancelTimerActivity();
       
  2291                             }
       
  2292                 if( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() )
       
  2293                     {
       
  2294                     FepUI()->HandleKeyL( EPtiKeyQwertyLeftShift, 
       
  2295                                                  EShortKeyPress );
       
  2296 					iFnCharInsertedForShift = ETrue;                                                    
       
  2297                     }                 
       
  2298                 }
       
  2299 #endif // Half Qwerty flag
       
  2300 #endif // ITI flag
       
  2301 
       
  2302             // Shift key is pressed down.
       
  2303             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2304             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2305             if ( IsFlagSet(EFlagQwertyShiftMode) && IsFlagSet(EFlagNoActionDuringShiftKeyPress) )
       
  2306                 {
       
  2307                 ClearFlag(EFlagQwertyShiftMode | EFlagNoActionDuringShiftKeyPress);
       
  2308                 // If long shift key press flag is set, then do not do manual case update.
       
  2309                 if (!IsFlagSet(EFlagLongShiftKeyPress))
       
  2310                     {
       
  2311                     iCaseMan->ManualCaseUpdate();
       
  2312                     }
       
  2313                 }
       
  2314             else
       
  2315                 {
       
  2316                 if (!(iCurrentFepUI->IsValidShiftKeyPress()))
       
  2317                     {
       
  2318                     return EKeyWasConsumed;
       
  2319                     }
       
  2320 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2321 #ifdef __HALF_QWERTY_KEYPAD                    
       
  2322                 if(!iFnCharInsertedForShift)
       
  2323 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2324 #endif //__HALF_QWERTY_KEYPAD                
       
  2325                 	{
       
  2326                 	SetFlag(EFlagQwertyShiftMode);
       
  2327                 	}
       
  2328 					
       
  2329                 if(iShiftKeypressMonitor->IsActive())
       
  2330                 	iShiftKeypressMonitor->Cancel();               	
       
  2331                 // Long press of shift key timer is activated.
       
  2332                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay, EShiftKeyRepeatDelay, 
       
  2333                     TCallBack(ResetShiftKeyMonitorCallback, this));
       
  2334 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2335                 // Shift kkey hack for GQF implementation. Need to check 
       
  2336                 // if it has any side effect.  
       
  2337                 if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
  2338                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
  2339                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyDown)
       
  2340                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext))
       
  2341 #endif
       
  2342                 UpdateIndicators();
       
  2343                 }
       
  2344             }
       
  2345         else if (aEventCode == EEventKeyUp)
       
  2346             {
       
  2347 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2348 #ifdef __HALF_QWERTY_KEYPAD            
       
  2349             if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2350                 iPtiEngine )
       
  2351                 {
       
  2352                 ClearCcpuFlag(ECcpuStateHashDown
       
  2353                       | ECcpuStateHashKeyDeleteDone
       
  2354                       | ECcpuStateChangeToPredictionMode);
       
  2355                 if (IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  2356                     {
       
  2357                     SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  2358                     ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  2359                     SetFlag(EFlagLongShiftKeyPress);
       
  2360 
       
  2361                     TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  2362                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);
       
  2363                     }
       
  2364                   if( CAknFepFnKeyManager::EFnKeyNone != FnKeyState())
       
  2365                       {
       
  2366                       ClearFlag(EFlagQwertyShiftMode);
       
  2367                       }
       
  2368                 //  iFnCharInsertedForShift = EFalse;    
       
  2369                   }
       
  2370                 
       
  2371 #endif // Half Qwerty flag
       
  2372 #endif // ITI flag
       
  2373 
       
  2374             ClearFlag(EFlagShiftKeyDepressed);
       
  2375             ClearCcpuFlag(ECcpuStateCbaShown);
       
  2376             if ( !IsFlagSet(EFlagNoActionDuringShiftKeyPress) ||
       
  2377                 (IsFlagSet(EFlagNoActionDuringShiftKeyPress) && IsFlagSet(EFlagLongShiftKeyPress)) )
       
  2378                 {
       
  2379                 ClearFlag(EFlagQwertyShiftMode);
       
  2380                 }
       
  2381 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  2382 #ifdef __HALF_QWERTY_KEYPAD				          
       
  2383             if( IsFlagSet(EFlagQwertyChrKeyDepressed) && IsFlagSet(EFlagNoActionDuringShiftKeyPress))
       
  2384                 {
       
  2385 #ifdef FF_DUAL_LANGUAGE_SUPPORT                    
       
  2386                  // Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  2387 				 // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  2388                 if(iKeyboardType == EPtiKeyboardHalfQwerty )
       
  2389                     LaunchDualLanguageSettingDialogL();
       
  2390                 else                     
       
  2391 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  2392                     LaunchLanguagesPopupListL();
       
  2393                 ClearFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress|EFlagNoActionDuringShiftKeyPress);                
       
  2394                 }
       
  2395                
       
  2396 #ifdef __SHIFT_KEY_LOOP                                
       
  2397             if( KeyboardLayout() == EPtiKeyboardHalfQwerty &&
       
  2398             // looping does not happen for long key press
       
  2399                 !IsFlagSet(EFlagLongShiftKeyPress) &&     
       
  2400             // looping does not happen in functionized state                
       
  2401                 iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNone &&
       
  2402             // looping happens only when no action 
       
  2403             // has happened when the shift key has been pressed     
       
  2404                  IsFlagSet(EFlagNoActionDuringShiftKeyPress) && !iFnCharInsertedForShift )
       
  2405                 {
       
  2406                 HandleKeyEventL( EStdKeyLeftShift, EShortKeyPress );
       
  2407                 ClearFlag(EFlagQwertyShiftMode);
       
  2408                 }
       
  2409         	iFnCharInsertedForShift = EFalse;        
       
  2410 #endif //__SHIFT_KEY_LOOP       
       
  2411 #endif //__HALF_QWERTY_KEYPAD      
       
  2412 #endif //RD_INTELLIGENT_TEXT_INPUT   
       
  2413             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  2414                 {
       
  2415                 ClearFlag(EFlagLongShiftKeyPress);
       
  2416                 }
       
  2417             else                                    // short keypress up
       
  2418                 {
       
  2419                 iShiftKeypressMonitor->Cancel();
       
  2420 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  2421 #ifdef __HALF_QWERTY_KEYPAD               
       
  2422 #ifdef __SHIFT_KEY_LOOP
       
  2423 				// Cancel multitap timer
       
  2424                 
       
  2425                 if( iPtiEngine != NULL )
       
  2426                     {
       
  2427 				    iPtiEngine->CancelTimerActivity();
       
  2428                     }
       
  2429 #endif //__SHIFT_KEY_LOOP       
       
  2430 #endif //__HALF_QWERTY_KEYPAD      
       
  2431 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2432                 }
       
  2433             ClearFlag( EFlagNoActionDuringShiftKeyPress );
       
  2434 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2435             // Shift kkey hack for GQF implementation. Need to check 
       
  2436                 // if it has any side effect.  
       
  2437             if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
  2438                 && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
  2439                 && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyDown)
       
  2440                 &&(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext))
       
  2441 #endif
       
  2442             UpdateIndicators();
       
  2443             }
       
  2444         }
       
  2445     else
       
  2446         {
       
  2447         if ( !iInputCapabilities.FepAwareTextEditor() && (!iCandidatePopup))
       
  2448             {
       
  2449             response = EKeyWasNotConsumed;
       
  2450             }        
       
  2451         else if (aEventCode == EEventKeyDown)
       
  2452             {
       
  2453             if (Japanese() && iInputCapabilities.FepAwareTextEditor())
       
  2454                 {
       
  2455                 if (!(iCurrentFepUI->IsValidShiftKeyPress()))
       
  2456                     {
       
  2457                     return EKeyWasConsumed;
       
  2458                     }
       
  2459                 TryCloseUiL();
       
  2460                 }
       
  2461             
       
  2462             // Shift key is pressed down but no any other key is pressed.
       
  2463             ClearCcpuFlag(ECcpuSupressEditMenuFromShiftUp);
       
  2464             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2465             if ( !(iAknEditorFlags & EAknEditorFlagNoLRNavigation))
       
  2466                 {
       
  2467                 // Cancel the timer first if active.
       
  2468                 // EEventKeyUp is not sent always for shift key during debugging on emulator.
       
  2469                 iShiftKeypressMonitor->Cancel();
       
  2470                 // Long press of shift key timer is activated.
       
  2471                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay, EShiftKeyRepeatDelay,
       
  2472                     TCallBack(ResetShiftKeyMonitorCallback, this));
       
  2473                 }
       
  2474             if ( IsFlagSet(EFlagInsideInlineEditingTransaction) &&
       
  2475                 WesternPredictive() && iFepManState == EAknFepStateUIActive )
       
  2476                 {
       
  2477                 TryRemoveNoMatchesIndicatorL();
       
  2478                 UpdateCbaL(NULL);
       
  2479                 }
       
  2480             }
       
  2481         else if (aEventCode == EEventKeyUp)
       
  2482             {
       
  2483             ClearFlag(EFlagShiftKeyDepressed);
       
  2484             ClearCcpuFlag(ECcpuStateCbaShown);
       
  2485             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  2486                 {
       
  2487                 ClearFlag(EFlagLongShiftKeyPress | EFlagNoActionDuringShiftKeyPress);
       
  2488                 // Shift long key press timer started, in between release of
       
  2489                 // Shift key should cancel active long shift key timer. 
       
  2490                 iShiftKeypressMonitor->Cancel();
       
  2491                 if (!iInputCapabilities.FepAwareTextEditor())
       
  2492                     {
       
  2493                     TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  2494                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKeyUp);                    
       
  2495                     }
       
  2496                 }
       
  2497             else                                    // short keypress up
       
  2498                 {
       
  2499                 iShiftKeypressMonitor->Cancel();
       
  2500                 if (!(iAknEditorFlags & EAknEditorFlagSupressShiftMenu) &&
       
  2501                     IsFlagSet(EFlagNoActionDuringShiftKeyPress) && //iCurrentFepUI->IsValidShiftKeyPress() &&
       
  2502                     !IsCcpuFlagSet(ECcpuSupressEditMenuFromShiftUp))
       
  2503                     {
       
  2504                     // Shift key is released before any other key is pressed.
       
  2505                     // Edit menu is launched if it is allowed.
       
  2506                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  2507                     //Check if pointer event drag is not there before launch of edit menu.
       
  2508                     if( !IsExtendedFlagSet(EExtendedFlagPointerEventTypeEDrag))
       
  2509                       	{
       
  2510                     	LaunchSelectModeMenuL();
       
  2511                     	}
       
  2512                    
       
  2513                     if (iInputCapabilities.FepAwareTextEditor())
       
  2514                         {
       
  2515                         response = EKeyWasConsumed;    
       
  2516                         }
       
  2517                     }
       
  2518                 }
       
  2519             }
       
  2520         }
       
  2521 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2522     if (aEventCode == EEventKeyUp && 
       
  2523         EPtiKeyboardQwerty4x10 == KeyboardLayout() && FepUI())
       
  2524 	    {
       
  2525 	    FepUI()->HandleKeyL(EKeyLeftShift, EShortKeyPress);
       
  2526 	    }
       
  2527 #endif	    
       
  2528     return response;
       
  2529     }
       
  2530 
       
  2531 TKeyResponse CAknFepManager::HandleThai0KeyEvent(TEventCode aEventCode, TKeyPressLength aLength, 
       
  2532                                                  TBool& aThai0KeyHandling)
       
  2533     {
       
  2534     TKeyResponse response = EKeyWasNotConsumed;
       
  2535     aThai0KeyHandling = EFalse;
       
  2536     if(iQwertyInputMode)
       
  2537         {
       
  2538         return response;    
       
  2539         }
       
  2540    
       
  2541     if ( iLanguageCapabilities.iInputLanguageCode == ELangThai && 
       
  2542          iMode != ENumber && iMode != ENativeNumber )
       
  2543         {
       
  2544         if (!IsPredictive())
       
  2545             {
       
  2546             if (aEventCode != EEventKeyUp)
       
  2547                 {
       
  2548                 response = EKeyWasConsumed;
       
  2549                 if ( aLength == ELongKeyPress)
       
  2550                     {
       
  2551                     if (!iLongThai0Key)
       
  2552                         {
       
  2553                         iLongThai0Key = ETrue;
       
  2554                         response = EKeyWasNotConsumed; // 0 to editor
       
  2555                         aThai0KeyHandling = ETrue;
       
  2556                         }
       
  2557                     }
       
  2558                 }
       
  2559 
       
  2560             else if (aEventCode == EEventKeyUp)
       
  2561                 {
       
  2562                 if (iLongThai0Key)
       
  2563                     {
       
  2564                     iLongThai0Key = EFalse;
       
  2565                     response = EKeyWasConsumed;
       
  2566                     }
       
  2567                 else
       
  2568                     {
       
  2569                     response = EKeyWasNotConsumed; // Show Thai 0 key SCT
       
  2570                     aThai0KeyHandling = ETrue;
       
  2571                     }
       
  2572                 }
       
  2573             }
       
  2574         }
       
  2575     return response;
       
  2576     }
       
  2577 
       
  2578 TBool CAknFepManager::HandleQwertyChrKeyEventL(TEventCode aEventCode)
       
  2579     {
       
  2580     TBool response = EFalse;
       
  2581     if ( !iQwertyInputMode || !iInputCapabilities.FepAwareTextEditor() )
       
  2582         {
       
  2583         return response;
       
  2584         }
       
  2585 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2586     if(IsFlagSet(EFlagShiftKeyDepressed))
       
  2587         {
       
  2588         iKeyPressedDuringShift = ETrue;
       
  2589         }
       
  2590 #ifdef __HALF_QWERTY_KEYPAD
       
  2591     
       
  2592         if( (aEventCode == EEventKeyUp) )
       
  2593             {
       
  2594             ClearFlag(EFlagQwertyChrKeyDepressed);
       
  2595             }
       
  2596         // Handle shift for Half Qwerty seperately
       
  2597         if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2598             iPtiEngine /*&&             
       
  2599             ( aEventCode == EEventKeyDown || aEventCode == EEventKeyUp ) */ && !IsFlagSet(EFlagShiftKeyDepressed))
       
  2600             {		
       
  2601 
       
  2602 			if( HandleChrKeyForHalfQwertyL(aEventCode) )
       
  2603 				{
       
  2604 				return ETrue;
       
  2605 				}							
       
  2606             }
       
  2607 #endif // Half Qwerty flag 
       
  2608         // This part of code for error fixing.
       
  2609         // whenever fep is Fnupper state, press of "CHR" key
       
  2610         // always launch SCT table.
       
  2611         if( (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)&&
       
  2612             (IsFlagSet(EFlagQwertyShiftMode) || IsFlagSet(EFlagLongShiftKeyPress)))
       
  2613             {
       
  2614             ClearFlag(EFlagNoActionDuringShiftKeyPress | EFlagLongShiftKeyPress | EFlagShiftKeyDepressed | EFlagQwertyShiftMode);
       
  2615             iShiftKeypressMonitor->Cancel();  
       
  2616             SetFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2617             return response;
       
  2618             }
       
  2619            
       
  2620 
       
  2621 #endif // ITI flag
       
  2622     if (aEventCode == EEventKeyDown)
       
  2623         {
       
  2624         SetFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2625         response = EFalse;
       
  2626 
       
  2627         if (IsFeatureSupportedJapanese() || 
       
  2628             ( IsChineseInputLanguage() 
       
  2629 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  2630             && KeyboardLayout() == EPtiKeyboardHalfQwerty
       
  2631 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2632             ) )
       
  2633             {
       
  2634             // start timer for Chr key long pressing
       
  2635             iChrKeypressMonitor->Start(EChrKeyRepeatDelay, EChrKeyRepeatDelay, 
       
  2636                 TCallBack(HandleChrKeyMonitorCallback, this));
       
  2637             }
       
  2638         }
       
  2639     else if (aEventCode == EEventKeyUp)
       
  2640         {
       
  2641         if (iChrKeypressMonitor->IsActive())
       
  2642             {
       
  2643             iChrKeypressMonitor->Cancel();
       
  2644             }
       
  2645 
       
  2646         if (IsFlagSet(EFlagShiftKeyDepressed) && IsFlagSet(EFlagNoActionDuringChrKeyPress)
       
  2647 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2648 		 	||
       
  2649             IsFlagSet(EFlagQwertyShiftMode)
       
  2650 #endif            	
       
  2651 			)
       
  2652             {
       
  2653             ClearFlag(EFlagNoActionDuringShiftKeyPress | EFlagLongShiftKeyPress | 
       
  2654                       EFlagShiftKeyDepressed | EFlagQwertyShiftMode |EFlagQwertyChrKeyDepressed);
       
  2655             iShiftKeypressMonitor->Cancel();
       
  2656 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2657             iKeyPressedDuringShift = EFalse;
       
  2658 #endif                 
       
  2659             UpdateIndicators();
       
  2660             // In Japanese variant, the selecting input language is unnecessary.
       
  2661 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2662             if (EPtiKeyboardQwerty4x10 == KeyboardLayout() || EPtiKeyboardHalfQwerty == KeyboardLayout())
       
  2663                 {
       
  2664             	if (!IsFeatureSupportedJapanese() && iCurrentFepUI->IsValidShiftKeyPress())
       
  2665 	                {
       
  2666 #ifdef FF_DUAL_LANGUAGE_SUPPORT	                
       
  2667 					// Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  2668 	                // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  2669 	                if(iKeyboardType == EPtiKeyboard12Key || iKeyboardType == EPtiKeyboardHalfQwerty )
       
  2670                         LaunchDualLanguageSettingDialogL();
       
  2671                     else                      
       
  2672 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  2673                     LaunchLanguagesPopupListL();
       
  2674 	                }
       
  2675                 }
       
  2676             else
       
  2677             	{
       
  2678 #endif            	
       
  2679             if (!IsFeatureSupportedJapanese() && iCurrentFepUI->IsValidShiftKeyPress())
       
  2680                 {
       
  2681                 LaunchLanguagesPopupListL();
       
  2682 	                }
       
  2683 #ifdef RD_INTELLIGENT_TEXT_INPUT	                
       
  2684                 }
       
  2685 #endif                
       
  2686             }
       
  2687         else if (IsFlagSet(EFlagNoActionDuringChrKeyPress))
       
  2688             {
       
  2689             // pass key to Chinese UI manager in Chinese qwerty input for sct table
       
  2690             if(IsChineseInputLanguage() && iMode != ELatin)
       
  2691                 {
       
  2692                 FepUI()->HandleKeyL(EStdKeyLeftFunc, EShortKeyPress);
       
  2693                 ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress );
       
  2694                 }
       
  2695             else if (Japanese())
       
  2696                 {
       
  2697                 if (iMode != EHiragana)
       
  2698                     {
       
  2699                     // Commit characters
       
  2700 #ifdef RD_INTELLIGENT_TEXT_INPUT                    
       
  2701                 	// Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
  2702 					// between two words and SCT is launched
       
  2703                     iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
  2704 #endif //RD_INTELLIGENT_TEXT_INPUT                    
       
  2705                     HandleChangeInFocus();
       
  2706                     LaunchSpecialCharacterTableL();
       
  2707                     }
       
  2708                 }
       
  2709             else if ( IsAbleToLaunchSCT() )
       
  2710                 {                
       
  2711 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
  2712                	// Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
  2713 				// between two words and SCT is launched
       
  2714                 iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
  2715 #endif //RD_INTELLIGENT_TEXT_INPUT                
       
  2716                 HandleChangeInFocus();
       
  2717                 LaunchSpecialCharacterTableL();
       
  2718                 }
       
  2719             else if(IsFlagSet(EFlagQwertyChrKeyDepressed))
       
  2720             	{
       
  2721 					 ClearFlag(EFlagQwertyChrKeyDepressed);
       
  2722             	}
       
  2723             }
       
  2724         else
       
  2725             {
       
  2726             FepUI()->ExpireMultitapTimer();
       
  2727             ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2728             
       
  2729             response = ETrue;
       
  2730             } 
       
  2731         }
       
  2732     return response;
       
  2733     }
       
  2734     
       
  2735 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2736 #ifdef __HALF_QWERTY_KEYPAD    
       
  2737 TKeyResponse CAknFepManager::HandleChrKeyForHalfQwertyL( TEventCode aEventCode)
       
  2738 	{
       
  2739 	if ((IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction)) && !(EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case()))
       
  2740         {
       
  2741         iPtiEngine->CancelTimerActivity();
       
  2742         }
       
  2743 	// in functionized mode the chr key is mapped to specific chars
       
  2744 	// and should therefore be handled by the states
       
  2745 	if ( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() || IsReverseFnkeyInput())
       
  2746 		{		
       
  2747 		if( aEventCode == EEventKeyDown && ( EditorHasFreeSpace() ||
       
  2748     		  IsFlagSet( EFlagInsideMultitapInlineEditingTransaction )))
       
  2749 			{
       
  2750 			FepUI()->HandleKeyL( EStdKeyLeftFunc, 
       
  2751 										 EShortKeyPress );			
       
  2752 			}
       
  2753 		return EKeyWasConsumed;
       
  2754 		}
       
  2755 	// in non-functionized predictive mode,
       
  2756 	// a long key press of the chr key should produce the SCT
       
  2757 	// a short key press should produce the candidate list
       
  2758 	if ( ( iWesternPredictive || IsChineseInputLanguage() ) /*&& 
       
  2759 	   ( iMode != EPinyin && iMode != EStroke && iMode != EZhuyin )*/ )
       
  2760 		{						
       
  2761 		
       
  2762 		if(!iChrKeypressMonitor->IsActive())
       
  2763 			{
       
  2764 			// this monitors long key presses of chr key
       
  2765 			// the framework does not give us the iRepeats info 
       
  2766 			// for chr key for some reason
       
  2767 			iChrKeypressMonitor->Start(EHalfQwertyChrKeyRepeatDelay, EHalfQwertyChrKeyRepeatDelay, 
       
  2768                 TCallBack(HandleChrKeyMonitorCallback, this));			
       
  2769 			}
       
  2770 
       
  2771 		if( aEventCode != EEventKeyUp )
       
  2772 			{
       
  2773 			SetFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2774 			return EKeyWasConsumed;
       
  2775 			}
       
  2776 
       
  2777 		if ( aEventCode == EEventKeyUp && IsFlagSet(EFlagNoActionDuringChrKeyPress) )
       
  2778 			{
       
  2779 			if(!iChrLongKeyPress )
       
  2780 				{							
       
  2781 				// if we have come here it's a short press
       
  2782 				// the flag EFlagNoActionDuringChrKeyPress is cleared in the timer callback
       
  2783 				if(!IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) || IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
  2784 					{
       
  2785 					// when not in inline editing mode,
       
  2786 					// chr key should produce the SCT
       
  2787 					if ( !IsChineseInputLanguage() )
       
  2788 						{
       
  2789 						LaunchSpecialCharacterTableL();	
       
  2790 						}
       
  2791 					else
       
  2792 						{
       
  2793 						FepUI()->HandleKeyL( EStdKeyLeftFunc, 
       
  2794 								 EShortKeyPress );
       
  2795 						}
       
  2796 					}				
       
  2797 				ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);			
       
  2798 
       
  2799 				iChrKeypressMonitor->Cancel();			
       
  2800 
       
  2801 				TInt wordToFocus = KWordToFocusInCandidateList;
       
  2802 				TInt numberOfCandidates = iPtiEngine->NumberOfCandidates();
       
  2803 				if (numberOfCandidates > 1)
       
  2804 				{
       
  2805 				wordToFocus = KWordToFocusInCandidateList;
       
  2806 				}
       
  2807 				LaunchCandidatePopupListL(wordToFocus);
       
  2808 
       
  2809 				return EKeyWasConsumed;
       
  2810 				}
       
  2811 			else 
       
  2812 				{
       
  2813 
       
  2814 		    	
       
  2815 		    	// Cancel the timer    	
       
  2816 		    	iChrKeypressMonitor->Cancel();
       
  2817 		    	
       
  2818 		    	// commit the characters
       
  2819 	        	HandleChangeInFocus();
       
  2820 
       
  2821 		    	// Clear the chr key depressed flag
       
  2822 		    	ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2823 		        // launch the special character table
       
  2824 		        iChrLongKeyPress = EFalse;
       
  2825 		        
       
  2826 		        if ( IsAbleToLaunchSCT() )
       
  2827 		            {
       
  2828 		            LaunchSpecialCharacterTableL();
       
  2829 		            }
       
  2830 
       
  2831 		        return EKeyWasConsumed;
       
  2832 				}	
       
  2833 			}
       
  2834 		else
       
  2835 			{
       
  2836 			return EKeyWasNotConsumed;
       
  2837 			}
       
  2838 		}
       
  2839 	return EKeyWasNotConsumed;
       
  2840 	}			
       
  2841 #endif //__HALF_QWERTY_KEYPAD 
       
  2842 #endif //RD_INTELLIGENT_TEXT_INPUT				
       
  2843 
       
  2844 TKeyResponse CAknFepManager::HandleQwertyControlKeyEventL(const TKeyEvent& aKeyEvent, 
       
  2845                                                           TEventCode aEventCode)
       
  2846     {
       
  2847     TKeyResponse response = EKeyWasConsumed;
       
  2848 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2849      if (EPtiKeyboardQwerty4x10 == KeyboardLayout())
       
  2850      {
       
  2851      	if( iCurrentFepUI && !iCurrentFepUI->IsValidShiftKeyPress() && aEventCode == EEventKeyUp )
       
  2852      	{
       
  2853      	    FepUI()->HandleKeyL(EKeyLeftCtrl, EShortKeyPress);    
       
  2854      		return EKeyWasConsumed;
       
  2855      	}
       
  2856      }
       
  2857 #endif     
       
  2858 
       
  2859     // need to ignore [Ctrl] + the following simbol keys
       
  2860     // because FEP doesn't consume [Ctrl] combination keys.
       
  2861     if (Japanese() && aEventCode == EEventKey)
       
  2862         {
       
  2863         TBool comsume = EFalse;
       
  2864         switch (aKeyEvent.iScanCode)
       
  2865             {
       
  2866             case EStdKeyNkpPlus:
       
  2867             case EPtiKeyQwertyPlus:
       
  2868             case EPtiKeyQwertyMinus:
       
  2869             case EPtiKeyQwertyComma:
       
  2870             case EPtiKeyQwertySemicolon:
       
  2871             case EPtiKeyQwertyFullstop:
       
  2872             case EPtiKeyQwertyHash:
       
  2873             case EPtiKeyQwertySlash:
       
  2874             case EPtiKeyQwertyApostrophe:
       
  2875             case EPtiKeyQwertySpace:
       
  2876                 comsume = ETrue;
       
  2877                 break;
       
  2878             default:
       
  2879                 break;
       
  2880             }
       
  2881         if (comsume)
       
  2882             {
       
  2883             return EKeyWasConsumed;
       
  2884             }
       
  2885         }
       
  2886 
       
  2887 #ifdef RD_SCALABLE_UI_V2
       
  2888     if (aKeyEvent.iModifiers & EModifierCtrl
       
  2889     && (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyV || 
       
  2890         aKeyEvent.iScanCode == EPtiKeyQwertyX))
       
  2891         {
       
  2892         SendEventsToPluginManL( EPluginSyncFepAwareText );
       
  2893         // Let copy / cut / paste events to flow through.
       
  2894         response = EKeyWasNotConsumed;
       
  2895         }          
       
  2896 #endif         
       
  2897 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2898     // Predictive QWERTY (XT9) changes ---->
       
  2899     // Ctrl combinations which affect the editor state, must commit the current inline edit.
       
  2900     // Otherwise the currently active inline word might be lost.
       
  2901     if ( iWesternPredictive && iQwertyInputMode && IsFlagSet(EFlagInsideInlineEditingTransaction) )
       
  2902         {
       
  2903         switch (aKeyEvent.iScanCode)
       
  2904             {
       
  2905             case EStdKeyUpArrow:
       
  2906             case EStdKeyDownArrow:
       
  2907             case EStdKeyLeftArrow:
       
  2908             case EStdKeyRightArrow:
       
  2909             case EPtiKeyQwertyC:
       
  2910             case EPtiKeyQwertyV:
       
  2911             case EPtiKeyQwertyX:
       
  2912             case EPtiKeyQwertyA:
       
  2913                 iPtiEngine->CommitCurrentWord();
       
  2914                 TryCloseUiL();        
       
  2915                 break;
       
  2916             default:
       
  2917                 break;
       
  2918             }
       
  2919         }
       
  2920     // Predictive QWERTY (XT9) changes <----
       
  2921 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2922 
       
  2923     if (aEventCode != EEventKeyUp)
       
  2924         {
       
  2925         return EKeyWasNotConsumed;
       
  2926         }
       
  2927     
       
  2928     if(iQwertyInputMode)
       
  2929         {
       
  2930 
       
  2931 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2932         // Query ptiEngine to know if the scancode maps to EPtiKeyQwertyC, 
       
  2933         // EPtiKeyQwertyV or EPtiKeyQwertyX.
       
  2934         // we should not always rely on scancode as products may change it, while
       
  2935         // still having the 'C', 'V' and 'X' mappings
       
  2936         
       
  2937         TBuf<32> mapData;              
       
  2938         iPtiEngine->MappingDataForKey((TPtiKey)aKeyEvent.iScanCode, mapData, EPtiCaseUpper); 
       
  2939         
       
  2940         if( mapData.Length() > 0 )    
       
  2941         	{
       
  2942         	if( mapData[0] == EPtiKeyQwertyC || mapData[0] == EPtiKeyQwertyV ||
       
  2943         	mapData[0] == EPtiKeyQwertyX )
       
  2944         		{
       
  2945         		// Let copy / cut / paste events to flow through.
       
  2946             	response = EKeyWasNotConsumed;
       
  2947         		}
       
  2948         	}
       
  2949 #else     
       
  2950         if (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyV ||
       
  2951             aKeyEvent.iScanCode == EPtiKeyQwertyX)
       
  2952             {
       
  2953             // Let copy / cut / paste events to flow through.
       
  2954             response = EKeyWasNotConsumed;
       
  2955             }
       
  2956 #endif
       
  2957             
       
  2958             
       
  2959         if (aKeyEvent.iScanCode == EStdKeyRightShift || aKeyEvent.iScanCode == EStdKeyLeftShift
       
  2960 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2961 			||
       
  2962             IsFlagSet(EFlagQwertyShiftMode)
       
  2963 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2964 			)
       
  2965             {
       
  2966             if(!iInputCapabilities.FepAwareTextEditor())
       
  2967                 {
       
  2968                 response = EKeyWasNotConsumed;
       
  2969                 }
       
  2970             else
       
  2971                 {
       
  2972                 SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  2973                 if ( iMode != ENumber && iMode!= ENativeNumber )
       
  2974                     {
       
  2975                     iModeBefore = iMode;
       
  2976                     }
       
  2977 #ifdef RD_HINDI_PHONETIC_INPUT  
       
  2978                            
       
  2979                 if(iSharedDataInterface->InputTextLanguage() == KLangHindiPhonetic)    
       
  2980                     {
       
  2981                     TryChangePhoneticModeL();   
       
  2982                     }
       
  2983                 else
       
  2984                     {
       
  2985 #endif                  
       
  2986                     if((!(IsOnlyNumericPermitted() || 
       
  2987                          (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))) &&
       
  2988                        TAknFepUiIndicInputManager::IsIndicLangauge(
       
  2989                          (TLanguage)iSharedDataInterface->InputTextLanguage()))
       
  2990                         {
       
  2991                         if(iLanguageCapabilities.iInputLanguageCode == ELangEnglish)
       
  2992                             {
       
  2993                             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  2994                             }
       
  2995                         else
       
  2996                             {
       
  2997                             ChangeInputLanguageL(ELangEnglish); 
       
  2998                             }   
       
  2999                         }
       
  3000                     else
       
  3001                         {
       
  3002                         TryIncrementModeChineseQwertyL(iMode);  
       
  3003                         }  
       
  3004 #ifdef RD_HINDI_PHONETIC_INPUT        
       
  3005                     }   
       
  3006 #endif
       
  3007                 }
       
  3008             ClearFlag(EFlagShiftKeyDepressed);
       
  3009             if ( !IsFlagSet(EFlagNoActionDuringShiftKeyPress) ||
       
  3010                 (IsFlagSet(EFlagNoActionDuringShiftKeyPress) && IsFlagSet(EFlagLongShiftKeyPress)) )
       
  3011                 {
       
  3012                 ClearFlag(EFlagQwertyShiftMode);
       
  3013                 }
       
  3014             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  3015                 {
       
  3016                 ClearFlag(EFlagLongShiftKeyPress);
       
  3017                 }
       
  3018             else                                    // short keypress up
       
  3019                 {
       
  3020                 iShiftKeypressMonitor->Cancel();
       
  3021                 }
       
  3022             ClearFlag( EFlagNoActionDuringShiftKeyPress );
       
  3023             UpdateIndicators();
       
  3024             }
       
  3025         else if(aKeyEvent.iScanCode == EStdKeySpace) // switch between last used Chinese input mode and English
       
  3026             {
       
  3027 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3028             // Predictive QWERTY (XT9) changes ---->
       
  3029             // Toggle the predictive mode with ctrl+space
       
  3030             if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  3031                  !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  3032                  iMode == ELatin &&
       
  3033                  iLanguageCapabilities.iSupportsWesternQwertyPredictive )
       
  3034                 {
       
  3035                 if (iWesternPredictive)
       
  3036                     {
       
  3037                     //ProcessCommandL(EAknCmdT9PredictiveT9Off);
       
  3038                     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3039                     //HandleChangeInFocus();                    
       
  3040                     if (iMode != ELatin)
       
  3041                         {
       
  3042                         TryChangeModeL(ELatin);
       
  3043                         }
       
  3044                     else
       
  3045                         {
       
  3046 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3047                         RemoveSuggestedAdvanceCompletionL();
       
  3048 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  3049                         CommitInlineEditL();
       
  3050                         }
       
  3051                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
  3052                     SetWesternPredictive(EFalse);
       
  3053                     HandleChangeInFocus();
       
  3054                     }
       
  3055                 else
       
  3056                     {
       
  3057                     //ProcessCommandL(EAknCmdMultitapPredictiveT9On);
       
  3058                     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3059                     //HandleChangeInFocus();
       
  3060                     SetWesternPredictive(ETrue);
       
  3061                     TryCloseUiL();
       
  3062                     TryChangeModeL(ELatin);
       
  3063      				}              
       
  3064                 // Reset the function key state,if predictive mode is cahnged.
       
  3065 				if (iFnKeyManager)
       
  3066 					{
       
  3067 					iFnKeyManager->ClearFnKeyState();
       
  3068 					}
       
  3069                 }
       
  3070             else // Predictive QWERTY (XT9) changes <----
       
  3071                 {
       
  3072 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3073             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3074             if(iMode != iModeBefore && iMode != ENumber && iMode != ENativeNumber )
       
  3075                 {
       
  3076                 TInt mode = iMode;
       
  3077                 if(iMode != ELatin && iModeBefore != ELatin) // more than one Chinese input modes
       
  3078                     {
       
  3079                     TryChangeModeL(ELatin);
       
  3080                     }
       
  3081                 else
       
  3082                     {
       
  3083                     TryChangeToModeBeforeL();
       
  3084                     }
       
  3085                 iModeBefore = mode; // deposit previous input mode
       
  3086                 }
       
  3087 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3088             }
       
  3089 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3090             } 
       
  3091 #ifdef RD_INTELLIGENT_TEXT_INPUT //// Predictive QWERTY (XT9) changes: open the edit menu with Fn+space ---->
       
  3092         else if (aKeyEvent.iScanCode == EStdKeyLeftFunc)
       
  3093             {
       
  3094             LaunchSelectModeMenuL();
       
  3095             } // Predictive QWERTY (XT9) changes <----
       
  3096 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3097         }       
       
  3098 
       
  3099     if (IsCcpuFlagSet(ECcpuStatePosted))           
       
  3100         {
       
  3101 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3102         // Query ptiEngine to know if the scancode maps to EPtiKeyQwertyC, 
       
  3103         // EPtiKeyQwertyV or EPtiKeyQwertyX.
       
  3104         // we should not always rely on scancode as products may change it, while
       
  3105         // still having the 'C', 'V' and 'X' mappings
       
  3106         
       
  3107         TBuf<32> mapData;              
       
  3108         iPtiEngine->MappingDataForKey((TPtiKey)aKeyEvent.iScanCode, mapData, EPtiCaseUpper); 
       
  3109         
       
  3110         if( mapData.Length() > 0 )    
       
  3111         	{
       
  3112         	if( mapData[0] == EPtiKeyQwertyC || mapData[0] == EPtiKeyQwertyX )
       
  3113         		{
       
  3114 	            // Let copy / cut events to flow through.
       
  3115 	            response = EKeyWasNotConsumed;
       
  3116 	            }
       
  3117         	}
       
  3118 #else
       
  3119         if (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyX)          
       
  3120             {
       
  3121             // Let copy / cut events to flow through.
       
  3122             response = EKeyWasNotConsumed;
       
  3123             }        
       
  3124 #endif   
       
  3125         ResetCcpuFlags();               
       
  3126         }
       
  3127 
       
  3128 
       
  3129 //Removed as part of the fix STAA-7FXCTK 
       
  3130 
       
  3131 /*    if (EPtiKeyboardQwerty4x10 == KeyboardLayout())
       
  3132     	{
       
  3133     	FepUI()->HandleKeyL(EKeyLeftCtrl, EShortKeyPress);    
       
  3134    	}*/
       
  3135 
       
  3136 
       
  3137     return response;
       
  3138     }
       
  3139 
       
  3140 TBool CAknFepManager::HandleQwertyKeyEventL(const TKeyEvent& aKeyEvent, TKeyResponse& aResponse)
       
  3141     {
       
  3142     TBool keyHandled = EFalse;
       
  3143     aResponse = EKeyWasNotConsumed;
       
  3144 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  3145     if(iKeyBackSpaceHit && (EKeyBackspace != aKeyEvent.iCode || EStdKeyBackspace != aKeyEvent.iScanCode))
       
  3146         	iKeyBackSpaceHit = 0;
       
  3147         
       
  3148     if(IsMfneEditor())
       
  3149         {
       
  3150         // multi-field editors need the key event to be sent to them directly
       
  3151         // therefore not consuming it here
       
  3152         return EFalse;
       
  3153         }
       
  3154 
       
  3155     if(IsFlagSet(EFlagShiftKeyDepressed))
       
  3156         {
       
  3157         iKeyPressedDuringShift = ETrue; 
       
  3158         }  
       
  3159   // This part of code for error fixing
       
  3160     // After short pressing of Fn/shift, if user press enter key, delete key
       
  3161     // it will reset the shift key and Fn key state.
       
  3162     if( EKeyEnter == aKeyEvent.iCode || EStdKeyEnter == aKeyEvent.iScanCode|| 
       
  3163         EKeyBackspace == aKeyEvent.iCode || EStdKeyBackspace == aKeyEvent.iScanCode)
       
  3164         {
       
  3165 		// if the shift key is still depressed, 
       
  3166 		// don't clear the qwerty shift mode
       
  3167         if(!IsFlagSet(EFlagShiftKeyDepressed))
       
  3168         	ClearFlag(EFlagQwertyShiftMode);     
       
  3169         if( iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNext )
       
  3170             {
       
  3171             iFnKeyManager->ClearFnKeyState();
       
  3172             }
       
  3173         }
       
  3174 #endif    
       
  3175     
       
  3176     if ( iQwertyInputMode && 
       
  3177          ( EditorHasFreeSpace() || 
       
  3178 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__         
       
  3179 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  3180            KeyEventWillReplaceCharacter( aKeyEvent ) ||
       
  3181 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  3182 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__         
       
  3183            ( Japanese() && iFepManState == EAknFepStateUIActive ) ) )
       
  3184         {
       
  3185         if (IsFlagSet(EFlagPassNextKey))
       
  3186             {
       
  3187 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__            
       
  3188 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3189             // Don't clear the pass next flag yet on the simulated "rollback key"
       
  3190             // used with secret editors, the actual key code to be entered to the
       
  3191             // editor will follow next.
       
  3192             if ( aKeyEvent.iCode != EKeyF20 )
       
  3193 #endif // RD_INTELLIGENT_TEXT_INPUT          
       
  3194 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__          
       
  3195             ClearFlag(EFlagPassNextKey);
       
  3196             return ETrue;   
       
  3197             }        
       
  3198                  
       
  3199         TInt keyScanCode = aKeyEvent.iScanCode;
       
  3200 #if defined(__WINS__)
       
  3201         if ( keyScanCode == EStdKeyNkpPlus )
       
  3202             {
       
  3203             // Workaround solution for the qwerty '+' key in emulator environment.
       
  3204             // I did not find a way how to to configure epoc_352x416_Qwerty.ini to send '+' keyevent.
       
  3205             keyScanCode = 0x2b;  // '+' key.
       
  3206             }
       
  3207 #endif                 
       
  3208         TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);        
       
  3209 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3210         TInt keyLayout =iSharedDataInterface->KeyboardLayout();
       
  3211         if (IsOnlyNumericPermitted() && phoneIdle &&                
       
  3212 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
  3213             !iIsReverseFnkeyInput &&
       
  3214 #endif
       
  3215             (keyLayout != EPtiKeyboardHalfQwerty ))                
       
  3216 #else
       
  3217         if (IsOnlyNumericPermitted() && phoneIdle)                
       
  3218 #endif
       
  3219             {
       
  3220             return ETrue;          
       
  3221             }
       
  3222         //if this SpecialNumeric editor, do not consume event.    
       
  3223         if (IsOnlyNumericPermitted() && IsSpecialNumericEditor())
       
  3224         	{
       
  3225         	return EFalse;
       
  3226         	}    
       
  3227       
       
  3228         
       
  3229 #ifdef FF_HOME_SCREEN_EASY_DIALING
       
  3230 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3231         
       
  3232         // This piece of code part of error fixing
       
  3233         // The Fep will insert the char, if Phone application launch the
       
  3234         // Phone number acquire editor in idle mode
       
  3235         // Specially Fep does not maintain Fn key state for non Fepware editor.
       
  3236         // So, Intermediate state of FnKey like FnNext will not work
       
  3237         // Hold on Fn key modify the modifier of of key event.
       
  3238         const TBool fnDown = (aKeyEvent.iModifiers & EModifierRightFunc);        
       
  3239         if( phoneIdle && fnDown && iFnKeyManager )
       
  3240             {
       
  3241             iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyDown);
       
  3242             SetCase((TCase)EFnKeyLowerCase);
       
  3243             }
       
  3244 #endif  // RD_INTELLIGENT_TEXT_INPUT
       
  3245 #endif  // FF_HOME_SCREEN_EASY_DIALING
       
  3246         
       
  3247        
       
  3248         const TBool shifted = (aKeyEvent.iModifiers & (EModifierLeftShift | 
       
  3249                                EModifierRightShift | EModifierShift));
       
  3250         
       
  3251         // This is needed for forcing shif state if this is the first key press in
       
  3252         // phone idle.    
       
  3253         if (shifted && phoneIdle)                    
       
  3254             {
       
  3255             SetFlag(EFlagQwertyShiftMode);
       
  3256             }                           
       
  3257 
       
  3258             
       
  3259         if (aKeyEvent.iRepeats == 1)
       
  3260             {
       
  3261             iKeyRepeat = ELongKeyPress;
       
  3262             }
       
  3263         else
       
  3264             {
       
  3265             iKeyRepeat = EShortKeyPress;
       
  3266             }
       
  3267                                   
       
  3268         if ( IsFlagSet(EFlagShiftKeyDepressed) &&
       
  3269             IsChineseInputLanguage() &&
       
  3270             keyScanCode == EPtiKeyQwertySpace) 
       
  3271             {
       
  3272             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3273             ClearFlag(EFlagQwertyShiftMode);
       
  3274             ClearFlag(EFlagLongShiftKeyPress);
       
  3275             SetChangeModeByShiftAndSpace( ETrue );
       
  3276             TryIncrementChineseModeForQwertyL(iMode);
       
  3277             keyHandled = ETrue;
       
  3278             }
       
  3279 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3280 		else
       
  3281             {
       
  3282 	            if(iKeyRepeat == ELongKeyPress && iPtiEngine->CurrentWord().Length() == EMaximumFepWordLength)
       
  3283 	            {
       
  3284 	            	keyHandled = ETrue;
       
  3285 	            }
       
  3286 	            else
       
  3287 	            {
       
  3288 	            	keyHandled = FepUI()->HandleKeyL(keyScanCode, iKeyRepeat);     
       
  3289 					if( EPtiKeyboardHalfQwerty == KeyboardLayout() 
       
  3290 	            			&& iWesternPredictive
       
  3291 	            			&& iCaseMan->CurrentCase() != EAknEditorUpperCase )
       
  3292 	            		{
       
  3293 	            		ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  3294 	            		}
       
  3295 	            	if ( keyHandled && iFepManState == EAknFepStateUIActive 
       
  3296 	            			&& (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie) )
       
  3297 	            		{
       
  3298 	            		if ( EditorState() )
       
  3299 	            			{
       
  3300 		            		EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagChinesePopup );
       
  3301 	            			}
       
  3302 	            		}
       
  3303 	            }
       
  3304             }
       
  3305 #else
       
  3306         if (IsChineseInputLanguage() && keyScanCode == EStdKeyBackspace)
       
  3307             {
       
  3308             keyHandled = FepUI()->HandleKeyL(keyScanCode, iKeyRepeat);
       
  3309             }
       
  3310             else
       
  3311             {
       
  3312             keyHandled = FepUI()->HandleKeyL(keyScanCode, EShortKeyPress);      
       
  3313             }
       
  3314 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3315         
       
  3316         if (keyHandled)
       
  3317             {
       
  3318             aResponse = EKeyWasConsumed;
       
  3319 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3320             // Predictive QWERTY changes ---->
       
  3321             ShowExactWordPopupIfNecessaryL();
       
  3322             // Predictive QWERTY changes <----
       
  3323             }
       
  3324 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3325 
       
  3326             // The indicators should be updated only if the key was handled. Otherwise
       
  3327             // the shift-copy-pasting will mess up the indicators.
       
  3328 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3329     TInt language = iSharedDataInterface->InputTextLanguage();
       
  3330     TBool IsChineseInput = language == ELangTaiwanChinese||
       
  3331                            language == ELangHongKongChinese ||
       
  3332                            language == ELangPrcChinese;
       
  3333 #endif      
       
  3334        if ( !shifted  )
       
  3335             {           
       
  3336 #ifdef RD_INTELLIGENT_TEXT_INPUT     
       
  3337             if(IsChineseInput && (iKeyboardType!= EPtiKeyboardHalfQwerty)) 
       
  3338                 {
       
  3339                 ClearFlag(EFlagQwertyShiftMode);
       
  3340                 UpdateIndicators();      
       
  3341                 }
       
  3342             else if( keyHandled )
       
  3343                 {
       
  3344 #endif                 
       
  3345                 ClearFlag(EFlagQwertyShiftMode);
       
  3346                 UpdateIndicators();
       
  3347                 
       
  3348 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3349                 }
       
  3350 #endif
       
  3351             } 
       
  3352               
       
  3353 #ifdef RD_SCALABLE_UI_V2
       
  3354     if ( ( (keyScanCode >= EPtiKeyQwertyA && keyScanCode <= EPtiKeyQwertyZ) ||
       
  3355          (keyScanCode >= EPtiKeyQwerty0 && keyScanCode <= EPtiKeyQwerty9) ||
       
  3356          (keyScanCode == EStdKeyEnter) ||
       
  3357          (keyScanCode == EPtiKeyQwertyPlus) ||
       
  3358          (keyScanCode == EPtiKeyQwertyMinus) ||
       
  3359          (keyScanCode == EPtiKeyQwertyComma) ||
       
  3360          (keyScanCode == EPtiKeyQwertySemicolon) ||
       
  3361          (keyScanCode == EPtiKeyQwertyFullstop)  ||
       
  3362          (keyScanCode == EPtiKeyQwertyHash)  ||
       
  3363          (keyScanCode == EPtiKeyQwertySlash) ||
       
  3364          (keyScanCode == EPtiKeyQwertyApostrophe) )
       
  3365          && !( iFepPluginManager && iFepPluginManager->EnableITIOnFSQ() ) )          
       
  3366         {
       
  3367         SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3368         //iFepPluginManager->ClosePluginInputModeL(ETrue);
       
  3369         }
       
  3370     else if( keyHandled )
       
  3371         {
       
  3372         //for QWERTY, number only, the number is send to editor
       
  3373         //bypass FEP
       
  3374         SendEventsToPluginManL( EPluginSyncFepAwareText ); 
       
  3375         //iFepPluginManager->SyncFepAwareText();
       
  3376         }
       
  3377 #endif
       
  3378         }
       
  3379         
       
  3380 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  3381 
       
  3382         TInt lang = iSharedDataInterface->InputTextLanguage();
       
  3383 
       
  3384         if(lang == ELangTaiwanChinese||
       
  3385            lang == ELangHongKongChinese ||
       
  3386            lang == ELangPrcChinese)    
       
  3387             {        
       
  3388             if( iPtiEngine->CurrentLanguage()->LanguageCode()== ELangEnglish 
       
  3389                 && IsFlagSet(EFlagQwertyShiftMode)
       
  3390                 && !IsFlagSet(EFlagLongShiftKeyPress))
       
  3391                 {
       
  3392                 ClearFlag(EFlagQwertyShiftMode); 
       
  3393                 UpdateIndicators();  
       
  3394                 }
       
  3395             }
       
  3396 #endif // RD_INTELLIGENT_TEXT_INPUT  
       
  3397     iKeyRepeat = EShortKeyPress;        
       
  3398     return keyHandled;
       
  3399     }
       
  3400 
       
  3401 
       
  3402 
       
  3403 void CAknFepManager::CancelTransaction()
       
  3404     {
       
  3405     if (iInputCapabilities.FepAwareTextEditor() && IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3406         {
       
  3407         CancelInlineEdit();
       
  3408         }
       
  3409     }
       
  3410 
       
  3411 void CAknFepManager::IsOnHasChangedState()
       
  3412     {
       
  3413     }
       
  3414 
       
  3415 void CAknFepManager::OfferKeyEventL(TEventResponse& /*aEventResponse*/, 
       
  3416                                     const TKeyEvent& /*aKeyEvent*/, 
       
  3417                                     TEventCode /*aEventCode*/)
       
  3418     {
       
  3419     }
       
  3420 
       
  3421 void CAknFepManager::OfferPointerEventL(TEventResponse& /*aEventResponse*/, 
       
  3422                                         const TPointerEvent& /*aPointerEvent*/, 
       
  3423                                         const CCoeControl* /*aWindowOwningControl*/)
       
  3424     {
       
  3425     }
       
  3426 
       
  3427 void CAknFepManager::OfferPointerBufferReadyEventL(TEventResponse& /*aEventResponse*/, 
       
  3428                                                    const CCoeControl* /*aWindowOwningControl*/)
       
  3429     {
       
  3430     }
       
  3431 
       
  3432 TInt CAknFepManager::NumberOfAttributes() const
       
  3433     {
       
  3434     return 0;
       
  3435     }
       
  3436 
       
  3437 TUid CAknFepManager::AttributeAtIndex(TInt /*aIndex*/) const
       
  3438     {
       
  3439     return KNullUid;
       
  3440     }
       
  3441 
       
  3442 void CAknFepManager::WriteAttributeDataToStreamL(TUid /*aAttributeUid*/, RWriteStream& /*aStream*/) const
       
  3443     {
       
  3444     }
       
  3445 
       
  3446 void CAknFepManager::ReadAttributeDataFromStreamL(TUid /*aAttributeUid*/, RReadStream& /*aStream*/)
       
  3447     {
       
  3448     }
       
  3449 
       
  3450 void CAknFepManager::HandleGainingForeground()
       
  3451     {
       
  3452     if (iFepFullyConstructed)
       
  3453         {
       
  3454         ClearFlag(EFlagRemoveMatchesMenuItem);
       
  3455         ClearCcpuFlag(ECcpuStateHashDown | ECcpuStateSelectionEventPosted | 
       
  3456                       ECcpuStateEdwinInSelectionMode);
       
  3457         TRAPD(err, iPtiEngine->HandleCommandL(EPtiCommandReloadLearningInfo));
       
  3458         if (err != KErrNone)
       
  3459             {
       
  3460             CleanUpFep();
       
  3461             }
       
  3462         }
       
  3463 
       
  3464 #ifdef RD_SCALABLE_UI_V2        
       
  3465     CCoeControl* focusCtrl = static_cast<const CCoeAppUi*>(CCoeEnv::Static()->AppUi())->TopFocusedControl(); 
       
  3466     iGainForeground = ETrue;
       
  3467     /*if( iLoseForeAndGainFocus )
       
  3468         {
       
  3469         SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3470         }*/
       
  3471     if(focusCtrl && focusCtrl->IsFocused())
       
  3472         {
       
  3473         if(GetForegroundTaskAppWgId() == CCoeEnv::Static()->RootWin().Identifier())
       
  3474             //SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3475             TRAP_IGNORE(SendEventsToPluginManL( EPluginForegroundChanged, ETrue));            
       
  3476         }
       
  3477     else
       
  3478         {
       
  3479         if (iFepPluginManager) 
       
  3480             {
       
  3481             iFepPluginManager->HandleiDimGainForeground(ETrue);   
       
  3482             }            
       
  3483         }
       
  3484 #endif // RD_SCALABLE_UI_V2        
       
  3485     }
       
  3486 
       
  3487 void CAknFepManager::HandleLosingForeground()
       
  3488     {
       
  3489     if (iFepFullyConstructed)
       
  3490         {
       
  3491         // Forget the shift state on FEP switch (i.e. when application goes to background)
       
  3492         ClearFlag(EFlagQwertyShiftMode | EFlagShiftKeyDepressed | 
       
  3493                   EFlagLongShiftKeyPress | EFlagNoActionDuringShiftKeyPress);
       
  3494         }	
       
  3495     if (Japanese())
       
  3496         {
       
  3497         TRAP_IGNORE(TryCloseUiL());
       
  3498         }
       
  3499     if (IsChineseInputLanguage())
       
  3500         {
       
  3501         TRAP_IGNORE(TryCloseUiL());
       
  3502         }
       
  3503         
       
  3504 #ifdef RD_SCALABLE_UI_V2     
       
  3505     iGainForeground = EFalse;
       
  3506     //SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3507     TRAP_IGNORE(SendEventsToPluginManL( EPluginForegroundChanged, EFalse));            
       
  3508 #endif // RD_SCALABLE_UI_V2    
       
  3509     }
       
  3510 
       
  3511 void CAknFepManager::HandleChangeInFocus()
       
  3512     {
       
  3513     TRAPD(err, HandleChangeInFocusL());
       
  3514     if (err != KErrNone)
       
  3515         {
       
  3516         CleanUpFep();
       
  3517         }
       
  3518     }
       
  3519 
       
  3520 void CAknFepManager::HandleDestructionOfFocusedItem()
       
  3521     {
       
  3522     if (iInputCapabilities.FepAwareTextEditor())
       
  3523         {
       
  3524         iFocusedItemDestroy = ETrue;
       
  3525         if ( iFepManState == EAknFepStateUIActive )
       
  3526             {            
       
  3527             TRAP_IGNORE(SendEventsToPluginManL( EPluginFocusItemDestroy ));  
       
  3528             if (Japanese() && iAknEditorFlags & EAknEditorFlagFindPane)
       
  3529                 {
       
  3530                 // In case of Find pane while inputting japanese characters,
       
  3531                 // No update or commit characters.
       
  3532                 iPtiEngine->ClearCurrentWord();
       
  3533                 }
       
  3534 
       
  3535         #ifdef RD_SCALABLE_UI_V2
       
  3536             // For addition of ITI features on FSQ, 
       
  3537             // need to restore some values stored before opening FSQ
       
  3538             // When go into this section, 
       
  3539             // touch ui won't be closed by ClosePluginInputUiL,
       
  3540             // but need to restore fep state here            
       
  3541             if ( iFepPluginManager )
       
  3542             	{
       
  3543             	iFepPluginManager->ResetItiStateL();
       
  3544             	}
       
  3545         #endif
       
  3546             // Close UI
       
  3547             FepUI()->CloseUI();
       
  3548             }
       
  3549         else
       
  3550             {            
       
  3551             TRAP_IGNORE(SendEventsToPluginManL( EPluginFocusItemDestroy, ETrue ));  
       
  3552             }
       
  3553         iFocusedItemDestroy = EFalse;
       
  3554         }
       
  3555 
       
  3556     if ( !(IsFlagSet(EFlagForegroundUIComponentVisible) ||
       
  3557         IsFlagSet(EFlagMenuPaneVisible)) )
       
  3558         {
       
  3559         iLanguageCapabilities.iNumericEditorDigitType = EDigitTypeUnknown;
       
  3560         //UpdateLocalDigitMode();
       
  3561         }
       
  3562     if(IsFlagSet(EFlagForegroundUIComponentVisible))
       
  3563         {
       
  3564         ClearFlag(EFlagForegroundUIComponentVisible);
       
  3565         }
       
  3566 
       
  3567     ClearFlag( EFlagInsideInlineEditingTransaction |
       
  3568         EFlagInsideMultitapInlineEditingTransaction |
       
  3569         EFlagLineFeedCharacter | EFlagNoMatches );
       
  3570 
       
  3571     iInputCapabilities = NULL;
       
  3572     }
       
  3573 
       
  3574 void CAknFepManager::HandleAknEdwinStateEventL(CAknEdwinState* aAknEdwinState, 
       
  3575                                                EAknEdwinStateEvent aEventType)
       
  3576     {
       
  3577     if(aEventType == EAknEdwinDestroy)
       
  3578     	{
       
  3579 		// Reset the last focus editor when destroy it.
       
  3580         if ( aAknEdwinState == iLastFocusedEditor )
       
  3581             {
       
  3582             iLastFocusedEditor->SetObserver( NULL );
       
  3583             iLastFocusedEditor = NULL;
       
  3584             }
       
  3585         
       
  3586         // Whenever the editor is destroyed, we destroy all the UI components we launched
       
  3587         if(iFepAwareDialogParentEditor == NULL || 
       
  3588         		iFepAwareDialogParentEditor == aAknEdwinState)
       
  3589         	{
       
  3590             // EExtendedFlagEdwinEditorDestroyed flag is used to leave once the dialog is closed.
       
  3591             SetExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  3592             // Delete any candidate popup is launched
       
  3593             if(iCandidatePopup)
       
  3594                 {
       
  3595                 delete iCandidatePopup;
       
  3596                 iCandidatePopup = NULL;
       
  3597                 }        
       
  3598             // Delete anu UI components launched by Fep.
       
  3599             iUiInterface->DeleteDialogs();
       
  3600         	}
       
  3601     	}
       
  3602     if ( IsFepAwareTextEditor() )
       
  3603         {
       
  3604         CAknEdwinState* editorState = EditorState();
       
  3605         if ( editorState != aAknEdwinState || !iFepFullyConstructed )
       
  3606             {
       
  3607             // FEP state update is not needed because editor state of non-focused
       
  3608             // editor was changed.
       
  3609             return;
       
  3610             }
       
  3611 
       
  3612         switch (aEventType)
       
  3613             {
       
  3614             case EAknEdwinStateInputModeUpdate:
       
  3615                 {
       
  3616                 TUint currentInputMode = editorState->CurrentInputMode();
       
  3617                 if ( EditorModeFromFepMode(iMode) != currentInputMode )
       
  3618                     {
       
  3619                     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3620                         {
       
  3621                         TryRemoveNoMatchesIndicatorL();
       
  3622                         }
       
  3623                     UpdateCbaL(NULL);
       
  3624                     TryCloseUiL();
       
  3625                     ConfigureFEPFromEditorStateL();
       
  3626                     }
       
  3627                 }
       
  3628                 break;
       
  3629             case EAknEdwinStateCaseModeUpdate:
       
  3630                 {
       
  3631                 TInt currentCaseMode = editorState->CurrentCase();
       
  3632                 if ( currentCaseMode != iCaseMan->CurrentCase() )
       
  3633                     {
       
  3634                     iCaseMan->SetCurrentCase(currentCaseMode);
       
  3635                     }
       
  3636                 }
       
  3637                 break;
       
  3638             case EAknEdwinStateLocalLanguageUpdate:
       
  3639                 {
       
  3640                 TLanguage localLanguage = ELangTest;
       
  3641                 if (GetLocalLanguage( localLanguage ) )
       
  3642                     {
       
  3643                     iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
  3644                     if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
  3645                         {
       
  3646                         ChangeInputLanguageL(localLanguage);
       
  3647                         }
       
  3648                     }
       
  3649                 }
       
  3650                 break;
       
  3651             case EAknEdwinStateFlagsUpdate:
       
  3652                 {
       
  3653                 TInt oldEditorFlags = iAknEditorFlags;
       
  3654                 if(iAknEditorFlags != editorState->Flags())
       
  3655                     {
       
  3656                     iAknEditorFlags = editorState->Flags();
       
  3657                     UpdateLocalDigitMode();
       
  3658                     }
       
  3659                 if ( iAknEditorFlags != oldEditorFlags )
       
  3660                     {
       
  3661                     if ( (iAknEditorFlags & EAknEditorFlagNoT9) != 
       
  3662                          (oldEditorFlags & EAknEditorFlagNoT9))
       
  3663                         {
       
  3664                         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3665                             {
       
  3666                             TryRemoveNoMatchesIndicatorL();
       
  3667                             }
       
  3668                         UpdateCbaL(NULL);
       
  3669                         TryCloseUiL();
       
  3670                         ConfigureFEPFromEditorStateL();
       
  3671                         }
       
  3672 
       
  3673                     if ( (iAknEditorFlags & EAknEditorFlagNoEditIndicators) != 
       
  3674                          (oldEditorFlags & EAknEditorFlagNoEditIndicators))
       
  3675                         {
       
  3676                         // We only need to update indicators when EAknEditorFlagNoEditIndicators was modified.
       
  3677                         // Current Fep state is not lost.
       
  3678                         UpdateIndicators();
       
  3679                         }
       
  3680 
       
  3681                     if ( (iAknEditorFlags & EAknEditorFlagFixedCase) != 
       
  3682                          (oldEditorFlags & EAknEditorFlagFixedCase))
       
  3683                         {
       
  3684                         // We only need to update EFlagSupressAutoUpdate flag when the
       
  3685                         // EAknEditorFlagFixedCase was modified.
       
  3686                         // Current Fep state is not lost.
       
  3687                         if (iAknEditorFlags & EAknEditorFlagFixedCase)
       
  3688                             {
       
  3689                             SetFlag(EFlagSupressAutoUpdate);
       
  3690                             }
       
  3691                         else
       
  3692                             {
       
  3693                             ClearFlag(EFlagSupressAutoUpdate);
       
  3694                             }
       
  3695                         }
       
  3696                     }
       
  3697                 }
       
  3698                 break;
       
  3699             case EAknEdwinStateEventStateUpdate:
       
  3700                 {
       
  3701                 // Feps state is reseted and new state is fetched completelly from editor state.
       
  3702                 if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3703                     {
       
  3704                     TryRemoveNoMatchesIndicatorL();
       
  3705                     }
       
  3706                 UpdateCbaL(NULL);
       
  3707                 TryCloseUiL();
       
  3708                 ConfigureFEPFromEditorStateL();
       
  3709                 }
       
  3710                 break;           
       
  3711             case EAknSyncEdwinState:
       
  3712 #ifdef RD_SCALABLE_UI_V2
       
  3713                  if ( !IsCcpuFlagSet(ECcpuStateIgnoreNextEdwinSyncEvent) && iFepPluginManager &&
       
  3714                      iFepPluginManager->PluginInputMode() == EPluginInputModeNone )
       
  3715 #else
       
  3716                  if ( !IsCcpuFlagSet(ECcpuStateIgnoreNextEdwinSyncEvent) )
       
  3717 #endif                     
       
  3718                      {
       
  3719                      HandleChangeInFocusL();                        
       
  3720                      }
       
  3721                  else
       
  3722                     {
       
  3723                     ClearCcpuFlag(ECcpuStateIgnoreNextEdwinSyncEvent);
       
  3724                     }
       
  3725                  break;  
       
  3726                  
       
  3727 #ifdef RD_SCALABLE_UI_V2
       
  3728             case EAknActivatePenInputRequest:
       
  3729                 SendEventsToPluginManL( EPluginEditorActivate );
       
  3730                 break;
       
  3731             case EAknClosePenInputRequest:
       
  3732                 if ( iFepPluginManager )
       
  3733                     {
       
  3734                     iFepPluginManager->ClosePluginInputModeL( EFalse );
       
  3735                     }
       
  3736                 break;
       
  3737             case EAknEdwinStatePromptUpdate:
       
  3738                 SendEventsToPluginManL( EPluginPromptChanged ); 
       
  3739                 break;
       
  3740 #endif // RD_SCALABLE_UI_V2                
       
  3741             case EAknCursorPositionChanged:
       
  3742 #ifdef RD_SCALABLE_UI_V2  
       
  3743                 SendEventsToPluginManL( EPluginSyncFepAwareText );   
       
  3744                 HandleCopyCutStateL();    
       
  3745 #endif
       
  3746                 // whenever focus cahnged happen, internally
       
  3747                 // editor treat cursorposition change.
       
  3748                 // In between, if editor context not in inline edit state.
       
  3749                 // Try to update the case editor gets the focus, and editor
       
  3750                 // context come in inline state.                
       
  3751 				//iCaseMan->UpdateCase(ENullNaviEvent);	
       
  3752                 break;
       
  3753 
       
  3754             default:
       
  3755                 break;
       
  3756             }
       
  3757         }
       
  3758     }
       
  3759 
       
  3760 
       
  3761 CAknExtendedInputCapabilities::TEditorType CAknFepManager::EditorType() const
       
  3762     {
       
  3763     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  3764 
       
  3765     if ( mop )
       
  3766         {
       
  3767         CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  3768         mop->MopGetObject( extendedInputCapabilities );
       
  3769 
       
  3770         if ( extendedInputCapabilities && iInputCapabilities.FepAwareTextEditor() ) 
       
  3771             {
       
  3772             TInt type = extendedInputCapabilities->EditorType();                                     
       
  3773             return static_cast<CAknExtendedInputCapabilities::TEditorType>( type );
       
  3774             }
       
  3775         }
       
  3776         
       
  3777     return CAknExtendedInputCapabilities::EUndefined;
       
  3778     }
       
  3779 
       
  3780 TUint CAknFepManager::MIDPConstraint() const
       
  3781 	{
       
  3782 	TUint ConstraintValue=0xFFFFFFFF;
       
  3783 	MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  3784 	
       
  3785 	if ( mop )
       
  3786 		{
       
  3787 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  3788         mop->MopGetObject( extendedInputCapabilities );
       
  3789 		if ( extendedInputCapabilities && iInputCapabilities.FepAwareTextEditor() ) 
       
  3790 			{
       
  3791 			ConstraintValue = extendedInputCapabilities->MIDPConstrainst();
       
  3792 			}
       
  3793 		}
       
  3794 		return ConstraintValue;
       
  3795 	}
       
  3796     
       
  3797 TBool CAknFepManager::IsSpecialNumericEditor()
       
  3798 	{
       
  3799 	TBool JavaNumericEditor = EFalse;
       
  3800 	TUint ConstraintValue = MIDPConstraint();
       
  3801 	if((ConstraintValue & ESplConstraintMask) == ESplNumeric ||
       
  3802 	   (ConstraintValue & ESplConstraintMask) == ESplDecimal)
       
  3803 		JavaNumericEditor = ETrue;
       
  3804 	
       
  3805 	return JavaNumericEditor;
       
  3806 	
       
  3807 	}
       
  3808 #ifdef RD_SCALABLE_UI_V2
       
  3809 void CAknFepManager::HandleInputCapabilitiesEventL( TInt aEvent, TAny* /*aParams*/ )
       
  3810     {
       
  3811     switch (aEvent)
       
  3812         {
       
  3813         case CAknExtendedInputCapabilities::MAknEventObserver::EActivatePenInputRequest:
       
  3814             SendEventsToPluginManL( EPluginEditorActivate );
       
  3815             break;
       
  3816         case CAknExtendedInputCapabilities::MAknEventObserver::EPointerEventReceived:
       
  3817 
       
  3818 /* 
       
  3819 #ifdef RD_TACTILE_FEEDBACK
       
  3820             CAknExtendedInputCapabilities::
       
  3821                 MAknEventObserver::TPointerEventReceivedParams* params = 
       
  3822                     static_cast<CAknExtendedInputCapabilities::
       
  3823                 MAknEventObserver::TPointerEventReceivedParams*>(aParams);
       
  3824             if (params->iPointerEvent.iType == TPointerEvent::EButton1Down)            
       
  3825                 {
       
  3826                 
       
  3827                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3828                 if (feedback && iFepPluginManager && !iFepPluginManager->VKBIsOpened())
       
  3829                     {
       
  3830                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
  3831                     }
       
  3832                 }
       
  3833 #endif // RD_TACTILE_FEEDBACK
       
  3834 */
       
  3835             if( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  3836                 {
       
  3837                 if (IsFeatureSupportedJapanese())
       
  3838 			        {
       
  3839 			        TryCloseUiL();
       
  3840 			        }
       
  3841 			    else
       
  3842 			        {
       
  3843 #ifdef RD_INTELLIGENT_TEXT_INPUT			        
       
  3844 			        iPtiEngine->CommitCurrentWord();
       
  3845 					CommitInlineEditL();
       
  3846 			        TryCloseUiL();
       
  3847 
       
  3848 #else
       
  3849 					CommitInlineEditL();
       
  3850 #endif			        
       
  3851 			        }
       
  3852                 }
       
  3853             break;      
       
  3854         case CAknExtendedInputCapabilities::MAknEventObserver::EControlContentUpdatedInternally:
       
  3855             SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncAll );
       
  3856             break;
       
  3857         case CAknExtendedInputCapabilities::MAknEventObserver::EOpenStylusMenuCcpu:
       
  3858             // User has highlighted text and editor requests stylus ccpu popup menu
       
  3859             // to be displayed.        
       
  3860             LaunchStylusCcpuMenuL(iClickPoint);
       
  3861             break;
       
  3862         }    
       
  3863     }
       
  3864     
       
  3865 void CAknFepManager::SubmitInlineTextL( const TDesC& aData )
       
  3866     {
       
  3867     if(TextIsValidInEditor(aData))
       
  3868     	{
       
  3869     	StartInlineEditL(aData);
       
  3870     	CommitInlineEditL();
       
  3871     	}
       
  3872     }
       
  3873     
       
  3874 // for japanese  
       
  3875 void CAknFepManager::NotifyJapaneseSetting()
       
  3876     {
       
  3877 	TInt param = 0;
       
  3878     // Deleting direction ON(right side) / OFF(left side)
       
  3879     if (iSharedDataInterface->ClearDirection() == EClearDirectionRight)
       
  3880         {
       
  3881         param |= EPenInputJapaneseSettingDeletingDirection;
       
  3882         }
       
  3883     // Japanese predictive ON(predictive on) / OFF(predictive off)
       
  3884     if (iJapanesePredictive)
       
  3885         {
       
  3886         param |= EPenInputJapaneseSettingPredictive;
       
  3887         }
       
  3888     // Japanese HWR conversion ON / OFF
       
  3889     if (iSharedDataInterface->JapaneseHwrConversion() == EJapaneseConversionOn)
       
  3890         {
       
  3891         param |= EPenInputJapaneseSettingConversion;
       
  3892         }
       
  3893     // Japanese HWR conversion ON / OFF
       
  3894     if (iCharWidth == EFullWidthChar)
       
  3895         {
       
  3896         param |= EPenInputJapaneseSettingCharacterWidth;
       
  3897         }
       
  3898     // Japanese qwerty setting flag
       
  3899     TInt qwertflag = iSharedDataInterface->JapaneseQwertyFlags();
       
  3900     // Qwerty Comma
       
  3901     if (qwertflag & EJapQwertySettingComma)
       
  3902         {
       
  3903         param |= EPenInputJapaneseSettingQwertyComma;
       
  3904         }
       
  3905     // Qwerty Period
       
  3906     if (qwertflag & EJapQwertySettingPeriod)
       
  3907         {
       
  3908         param |= EPenInputJapaneseSettingQwertyPeriod;
       
  3909         }
       
  3910     // Qwerty Width Of Space
       
  3911     if (qwertflag & EJapQwertySettingSpaceFullWidth)
       
  3912         {
       
  3913         param |= EPenInputJapaneseSettingQwertyWidthOfSpace;
       
  3914         }
       
  3915     // Lunch SCT
       
  3916     if (IsAbleToLaunchSCT())
       
  3917         {
       
  3918         param |= EPenInputJapaneseSettingLunchSCT;
       
  3919         }
       
  3920 #ifdef RD_SCALABLE_UI_V2
       
  3921     // Set Japanese setting
       
  3922     if(iFepPluginManager->CurrentPluginInputFepUI())    
       
  3923         {
       
  3924         TRAP_IGNORE(iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
  3925                                              ECmdPenInputJapaneseSetting, param));
       
  3926         }
       
  3927 #endif //RD_SCALABLE_UI_V2    
       
  3928     }
       
  3929 
       
  3930 TBool CAknFepManager::FullyFepAwareTextEditor() const
       
  3931     {
       
  3932     if ( iInputCapabilities.FepAwareTextEditor() )
       
  3933         {
       
  3934         if ( EditorType() != CAknExtendedInputCapabilities::EMFNEBased )
       
  3935             {
       
  3936             return ETrue;
       
  3937             }
       
  3938         }
       
  3939         
       
  3940     return EFalse;
       
  3941     }
       
  3942 
       
  3943 TBool CAknFepManager::SemiFepAwareTextEditor( TBool aAtLeast ) const
       
  3944     {
       
  3945     if ( aAtLeast )
       
  3946         {
       
  3947         switch ( EditorType() )
       
  3948             {
       
  3949             case CAknExtendedInputCapabilities::EEdwinBased:
       
  3950             case CAknExtendedInputCapabilities::EMFNEBased:
       
  3951                 return ETrue;
       
  3952                 
       
  3953             default:
       
  3954                 return EFalse;
       
  3955             }
       
  3956         }
       
  3957     else
       
  3958         {
       
  3959         return EditorType() == CAknExtendedInputCapabilities::EMFNEBased;
       
  3960         }
       
  3961     }
       
  3962     
       
  3963 void CAknFepManager::ProcessEditorMenuCommand(TInt aCommand)
       
  3964     {
       
  3965     TRAP_IGNORE(ProcessCommandL(aCommand));    
       
  3966     }
       
  3967     
       
  3968 TInt CAknFepManager::GetPermittedEditorMenu(TBool aOnlyCount)
       
  3969     {
       
  3970     TInt count = 0;
       
  3971     TRAP_IGNORE(count = GetPermittedEditorMenuL(aOnlyCount));
       
  3972     return count;
       
  3973     }
       
  3974 
       
  3975 TInt CAknFepManager::GetPermittedEditorMenuL(TBool aOnlyCount)
       
  3976     {
       
  3977     
       
  3978     CAknEdwinState* editorState = NULL;
       
  3979     if (iInputCapabilities.FepAwareTextEditor())
       
  3980         {
       
  3981         editorState = EditorState();
       
  3982         }
       
  3983     
       
  3984     CAknFepUiInterfaceMenuBar* menuBar = NULL;
       
  3985 
       
  3986 	RPointerArray<CEikMenuPaneItem> editorMenuItemList;	
       
  3987     
       
  3988     CEikMenuPane* editorMenuPane = new (ELeave) CEikMenuPane((MEikMenuObserver*)(this));
       
  3989     editorMenuPane->SetItemArrayOwnedExternally(EFalse);
       
  3990     TResourceReader reader;
       
  3991     CCoeEnv::Static()->CreateResourceReaderLC(reader, R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU);//
       
  3992         
       
  3993     const TInt menuCount=reader.ReadInt16();
       
  3994     for ( TInt ii=0; ii<menuCount; ++ii )
       
  3995         {
       
  3996         CEikMenuPaneItem* item = new(ELeave) CEikMenuPaneItem();
       
  3997         CleanupStack::PushL( item );
       
  3998         item->iData.iCommandId = reader.ReadInt32();
       
  3999         item->iData.iCascadeId = reader.ReadInt32();
       
  4000         item->iData.iFlags = reader.ReadInt32();
       
  4001         TPtrC txtptr = reader.ReadTPtrC();
       
  4002         item->SetScaleableTextL( txtptr );
       
  4003         TPtrC extratxtptr = reader.ReadTPtrC();
       
  4004         item->iData.iExtraText = extratxtptr;
       
  4005         TPtrC bitmapFile = reader.ReadTPtrC();
       
  4006         TInt bitmapId = reader.ReadInt16();
       
  4007         TInt bitmapMaskId = reader.ReadInt16();
       
  4008         CleanupStack::Pop(); // pop first, since additem pushes again
       
  4009         editorMenuPane->AddMenuItemL( item->iData );
       
  4010         editorMenuItemList.Append(item);
       
  4011         reader.ReadInt32(); // extension link
       
  4012         }
       
  4013         
       
  4014     CleanupStack::PopAndDestroy(); //reader 
       
  4015 
       
  4016             
       
  4017     if (editorState)
       
  4018         {
       
  4019         menuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  4020         }
       
  4021     
       
  4022     TInt count = 0;            
       
  4023     
       
  4024     if ( menuBar )
       
  4025         {
       
  4026         CAknFepUiInterfaceMenuPane* menuPane = menuBar->MenuPane();
       
  4027 
       
  4028         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();
       
  4029    
       
  4030         menuPane->SetMenuPane(editorMenuPane);             
       
  4031              
       
  4032         DynInitTouchMenuPaneL(menuPane);
       
  4033         
       
  4034         menuPane->SetMenuPane(oldMenuPane);
       
  4035                 
       
  4036 
       
  4037         for (TInt ii = 0; ii < KMaxMenuSize; ii++)
       
  4038             {
       
  4039             CEikMenuPaneItem::SData& itemdata = 
       
  4040                         editorMenuPane->ItemData(KEditorMenuPermitedSend[ii]);
       
  4041             if ( !(itemdata.iFlags & EEikMenuItemDimmed ) )
       
  4042                 {
       
  4043                 count = count + 1;
       
  4044                 iEditorCommandList[count] = itemdata.iCommandId; 
       
  4045                 }
       
  4046             }
       
  4047         iEditorCommandList[0] = count;
       
  4048         if (!aOnlyCount && iFepPluginManager->CurrentPluginInputFepUI())
       
  4049             {
       
  4050             iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
  4051                         ECmdPenInputSendEditMenuData, reinterpret_cast<TInt>(iEditorCommandList));
       
  4052             }
       
  4053         
       
  4054         editorMenuItemList.ResetAndDestroy();
       
  4055         delete editorMenuPane;
       
  4056         editorMenuPane = NULL;
       
  4057         }
       
  4058     
       
  4059     return count;
       
  4060     }
       
  4061 #endif // RD_SCALABLE_UI_V2
       
  4062 
       
  4063 void CAknFepManager::ExitPluginSpellModeByOk()
       
  4064     {
       
  4065     TRAP_IGNORE(ExitPluginSpellModeByOkL());
       
  4066     }
       
  4067 
       
  4068 void CAknFepManager::ExitPluginSpellModeByOkL()
       
  4069     {
       
  4070 #ifdef RD_SCALABLE_UI_V2        		    
       
  4071     if (iFepPluginManager->IsSpellVisible())
       
  4072         {
       
  4073         HBufC* spell = iFepPluginManager->SpellTextInput();
       
  4074         
       
  4075         iFepPluginManager->SetITUTSpellingStateL(EFalse); 
       
  4076         iFepPluginManager->DestroySpellEditor();
       
  4077         
       
  4078         if (spell)
       
  4079             {
       
  4080             CleanupStack::PushL(spell);
       
  4081             TPtr text = spell->Des();
       
  4082             FepUI()->AddTextToUserDictionaryL(text);
       
  4083             InsertTextFromDialogL(text, iFepPluginManager->CursorSelection());
       
  4084             CleanupStack::PopAndDestroy(spell);
       
  4085             }
       
  4086         
       
  4087         UpdateCbaL(NULL); 
       
  4088         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4089             {
       
  4090             SetFlag(EFlagSupressAutoUpdate);
       
  4091             }
       
  4092         else
       
  4093             {
       
  4094             ClearFlag(EFlagSupressAutoUpdate);
       
  4095             }
       
  4096         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4097         }
       
  4098 #endif       		    
       
  4099     }
       
  4100 
       
  4101 void CAknFepManager::ExitPluginSpellModeByCancel()
       
  4102     {
       
  4103 /*    
       
  4104 #ifdef RD_SCALABLE_UI_V2
       
  4105     if (iFepPluginManager->IsSpellVisible())
       
  4106         {
       
  4107         iFepPluginManager->SetITUTSpellingStateL(EFalse); 
       
  4108         iFepPluginManager->DestroySpellEditor();
       
  4109         UpdateCbaL(NULL);
       
  4110         HandleChangeInFocus();
       
  4111         if (iFepPluginManager->CursorSelection().Length())
       
  4112             {
       
  4113             EditorState()->SetInlineEditSpan(iFepPluginManager->CursorSelection());
       
  4114             ConfigureFEPFromEditorStateL();
       
  4115             }
       
  4116         TransferFepStateToEditorL();
       
  4117 
       
  4118         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4119             {
       
  4120             SetFlag(EFlagSupressAutoUpdate);
       
  4121             }
       
  4122         else
       
  4123             {
       
  4124             ClearFlag(EFlagSupressAutoUpdate);
       
  4125             }
       
  4126         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4127         iFepPluginManager->SetBeforeSpell(ETrue);
       
  4128         }
       
  4129 #endif
       
  4130 */
       
  4131 #ifdef RD_SCALABLE_UI_V2
       
  4132     if (iFepPluginManager->IsSpellVisible())
       
  4133         {
       
  4134         TRAP_IGNORE(iFepPluginManager->SetITUTSpellingStateL(EFalse)); 
       
  4135         iFepPluginManager->DestroySpellEditor();
       
  4136 
       
  4137         TRAP_IGNORE(UpdateCbaL(NULL)); 
       
  4138         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4139             {
       
  4140             SetFlag(EFlagSupressAutoUpdate);
       
  4141             }
       
  4142         else
       
  4143             {
       
  4144             ClearFlag(EFlagSupressAutoUpdate);
       
  4145             }
       
  4146         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4147         }
       
  4148 #endif       		
       
  4149     }
       
  4150 
       
  4151 void CAknFepManager::ProcessCommandL(TInt aCommandId)
       
  4152     {
       
  4153     //ProcessCommandL() is called before HandleChangeInFocus() for the editor to insert the
       
  4154     //number into, so have to force a call
       
  4155     
       
  4156     //Process pen input menu if avaliable
       
  4157 #ifdef RD_SCALABLE_UI_V2
       
  4158 
       
  4159      if (iFepPluginManager && 
       
  4160         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut)) 
       
  4161        	{
       
  4162        	switch(aCommandId)
       
  4163        		{
       
  4164        		case EAknSoftkeyOptions:
       
  4165        		    {
       
  4166        		    LaunchSelectModeMenuL();
       
  4167        		    }
       
  4168        		    return;
       
  4169        		case EAknSoftkeyOk:
       
  4170        		    {
       
  4171                 iFepPluginManager->ClosePluginInputModeL(ETrue);
       
  4172        		    }
       
  4173        		    return;
       
  4174        		default:
       
  4175        			{
       
  4176        			break;
       
  4177        			}
       
  4178        		}
       
  4179        	}
       
  4180 
       
  4181     SendEventsToPluginManL( EPluginMenuCmd, aCommandId );
       
  4182 
       
  4183 #endif //RD_SCALABLE_UI_V2
       
  4184     MAknFepManagerInterface* currentFepUI=NULL;
       
  4185     switch (aCommandId)
       
  4186         {
       
  4187         // Edit mode menu commands
       
  4188         //The soft CBA event from touch screen. 
       
  4189         case EAknSoftkeyCancel:
       
  4190       //  case (TUint16)EAknSoftkeyCancel:
       
  4191         case EAknSoftkeySelect:
       
  4192      //   case (TUint16)EAknSoftkeySelect:
       
  4193         currentFepUI = FepUI();
       
  4194         if (currentFepUI)
       
  4195             currentFepUI->HandleCommandL( aCommandId );
       
  4196             break;
       
  4197         // --- commands for Japanese ---
       
  4198         case EJapanFepCmdModeHiragana:
       
  4199             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4200             HandleChangeInFocus();
       
  4201             TryChangeModeL(EHiraganaKanji);
       
  4202             break;
       
  4203         case EJapanFepCmdModeKatakana:
       
  4204             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4205             HandleChangeInFocus();
       
  4206             TryChangeModeL(EKatakana);
       
  4207             break;
       
  4208         case EAknCmdEditInsertPictograph:
       
  4209             SetStopProcessFocus(ETrue);            
       
  4210             HandleChangeInFocus();
       
  4211             LaunchPictographCharacterTableL();
       
  4212             SetStopProcessFocus(EFalse);            
       
  4213             break;
       
  4214         case EJapanFepCmdModeFullWidth:
       
  4215         case EPenInputJpCmdFullWidth:
       
  4216         case EJapanFepCmdModeHalfWidth:
       
  4217         case EPenInputJpCmdHalfWidth:
       
  4218             {
       
  4219             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4220             HandleChangeInFocus();
       
  4221             if (aCommandId == EJapanFepCmdModeFullWidth
       
  4222              || aCommandId == EPenInputJpCmdFullWidth)
       
  4223                 {
       
  4224                 iCharWidth = EFullWidthChar;
       
  4225                 }
       
  4226             else
       
  4227                 {
       
  4228                 iCharWidth = EHalfWidthChar;
       
  4229                 }
       
  4230             UpdateIndicators();
       
  4231             TryChangeModeL(iMode);
       
  4232 #ifdef RD_SCALABLE_UI_V2
       
  4233             if (aCommandId == EPenInputJpCmdFullWidth
       
  4234              || aCommandId == EPenInputJpCmdHalfWidth)
       
  4235                 {
       
  4236                 // Re-open pen input window
       
  4237                 SendEventsToPluginManL( EPluginActivate );  
       
  4238                 }
       
  4239 #endif //RD_SCALABLE_UI_V2
       
  4240             }
       
  4241             break;
       
  4242         case EJapanFepCmdModeUserDic:
       
  4243         case EPenInputJpCmdSaveWord:
       
  4244             {
       
  4245             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4246             // User dictionary
       
  4247 #ifdef RD_PF_SEC_APPARC
       
  4248             // Launch settings app
       
  4249             if ( iNullService )
       
  4250                 {
       
  4251                 delete iNullService;
       
  4252                 iNullService = NULL;
       
  4253                 }
       
  4254             iNullService = CAknNullService::NewL( KUidUserDictApp, this );
       
  4255 #else
       
  4256             CEikProcess* process = CEikonEnv::Static()->Process();
       
  4257             if (iEmbedded)
       
  4258                 {
       
  4259                 process->DestroyDocument(iEmbedded);
       
  4260                 }
       
  4261 #if (defined(SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1) || defined(__SERIES60_27__) || defined(__SERIES60_28__)) 
       
  4262             iEmbedded = process->AddNewDocumentL(_L("User Dictionary"), KUidUserDictApp);
       
  4263 #else
       
  4264             iEmbedded = process->AddNewDocumentL(KUidUserDictApp);
       
  4265 #endif
       
  4266             iEmbedded->NewDocumentL();
       
  4267             iEmbedded->EditL(NULL);
       
  4268 #endif //RD_PF_SEC_APPARC
       
  4269             }
       
  4270             break;
       
  4271         case EPenInputJpCmdKutenCode:
       
  4272         case EJapanFepCmdModeKutenCodeInput:
       
  4273             {
       
  4274             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4275             LaunchKutenCodeQueryL();
       
  4276 #ifdef RD_SCALABLE_UI_V2
       
  4277             if (aCommandId == EPenInputJpCmdKutenCode)
       
  4278                 {
       
  4279                 // Re-open pen input window
       
  4280                 SendEventsToPluginManL( EPluginActivate );
       
  4281                 }
       
  4282 #endif //RD_SCALABLE_UI_V2
       
  4283             }
       
  4284             break;
       
  4285         case EAknCmdEditClearDirectionLeft:
       
  4286         case EAknCmdEditClearDirectionRight:
       
  4287             {
       
  4288             TInt value = EClearDirectionLeft;
       
  4289             if (aCommandId == EAknCmdEditClearDirectionRight)
       
  4290                 {
       
  4291                 value = EClearDirectionRight;
       
  4292                 }
       
  4293             iSharedDataInterface->SetClearDirection(value);
       
  4294             }
       
  4295             break;
       
  4296         case EAknFepSoftkeyCloseWindow:
       
  4297             if(IsChineseInputLanguage())
       
  4298                 {
       
  4299                 TryCloseUiL();
       
  4300                 }                        
       
  4301             if (iCcpuMode != ECcpuStateNone)
       
  4302                 {
       
  4303                 ResetCcpuFlags();
       
  4304 
       
  4305                 // reset select mode indicators
       
  4306                 iIndicator->SetCopyMode(EFalse);
       
  4307                 // update view                
       
  4308                 iPreviousEditingState = EStateNone;
       
  4309                 UpdateIndicators();
       
  4310 
       
  4311                 iUiInterface->DeleteSoftkeys();                              
       
  4312                 break;
       
  4313                 }
       
  4314         case EAknFepSoftkeyCommit:
       
  4315         case EAknFepSoftkeySelectCandidate:
       
  4316         case EAknFepSoftkeyConvert:
       
  4317         case EAknFepSoftkeyOtherModes:
       
  4318         case EAknFepSoftkeyRetroActiveHalf:
       
  4319         case EAknFepSoftkeyRetroActiveFull:
       
  4320             {
       
  4321             FepUI()->HandleCommandL(aCommandId);
       
  4322             }
       
  4323             break;
       
  4324         case EAknFepSoftkeyPredictiveOn:
       
  4325             {
       
  4326             iJapanesePredictive = ETrue;
       
  4327             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4328             iHashKeyMan->SetMode(iMode, ETrue);
       
  4329             UpdateIndicators();
       
  4330             FepUI()->HandleCommandL(aCommandId);
       
  4331             }
       
  4332             break;
       
  4333         case EJapanFepCmdModePredictiveOn:
       
  4334             {
       
  4335             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4336             HandleChangeInFocus();
       
  4337             if (!iJapanesePredictive)
       
  4338                 {
       
  4339                 LaunchConfirmationNoteL(R_AVKON_JAPANESE_PREDICTIVE_ACTIVATED_NOTE);
       
  4340                 }
       
  4341             iJapanesePredictive = ETrue;
       
  4342             TryChangeModeL(EHiraganaKanji);
       
  4343             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4344             }
       
  4345             break;
       
  4346         case EJapanFepCmdModePredictiveOff:
       
  4347             {
       
  4348             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4349             HandleChangeInFocus();
       
  4350             if (iJapanesePredictive)
       
  4351                 {
       
  4352                 LaunchConfirmationNoteL(R_AVKON_JAPANESE_PREDICTIVE_DEACTIVATED_NOTE);
       
  4353                 }
       
  4354             iJapanesePredictive = EFalse;
       
  4355             TryChangeModeL(EHiraganaKanji);
       
  4356             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
  4357             }
       
  4358             break;
       
  4359 #ifdef RD_SCALABLE_UI_V2
       
  4360         case EPenInputJpCmdPredictiveOn:
       
  4361             {
       
  4362             iJapanesePredictive = ETrue;
       
  4363             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4364             if (iFepPluginManager->PluginInputMode() == EPluginInputModeHwr)
       
  4365                 {
       
  4366                 iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOn);
       
  4367                 }
       
  4368             }
       
  4369             break;
       
  4370         case EPenInputJpCmdPredictiveOff:
       
  4371             {
       
  4372             iJapanesePredictive = EFalse;
       
  4373             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
  4374             }
       
  4375             break;
       
  4376         case EPenInputJpCmdConversionOn:
       
  4377             {
       
  4378             iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOn);
       
  4379             }
       
  4380             break;
       
  4381         case EPenInputJpCmdConversionOff:
       
  4382             {
       
  4383             iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOff);
       
  4384             }
       
  4385             break;
       
  4386 #endif //RD_SCALABLE_UI_V2
       
  4387 
       
  4388         // --- commands for Chinese ---
       
  4389         case EChinFepCmdModePinyin:
       
  4390             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4391             HandleChangeInFocus();
       
  4392             TryChangeModeL(EPinyin);
       
  4393             break;
       
  4394         case EChinFepCmdModeZhuyin:
       
  4395             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4396             HandleChangeInFocus();
       
  4397             TryChangeModeL(EZhuyin);
       
  4398             break;
       
  4399         case EChinFepCmdModeStroke:
       
  4400             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4401             HandleChangeInFocus();
       
  4402             TryChangeModeL(EStroke);
       
  4403             break;
       
  4404         case EChinFepCmdModeCangJie:
       
  4405             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4406             HandleChangeInFocus();
       
  4407             TryChangeModeL(ECangJie);
       
  4408             break;
       
  4409         case EChinFepCmdModeCangJieOption:
       
  4410             // Launch CangJie option dialog
       
  4411             {
       
  4412             SetStopProcessFocus(ETrue);
       
  4413             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4414             TInt newMode = LaunchCangJieOptionDlgL();
       
  4415             SetStopProcessFocus(EFalse);
       
  4416             UpdateCangJieState( newMode );
       
  4417             }
       
  4418             break;
       
  4419         case EChinFepCmdModeLatinUpper:
       
  4420             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4421             HandleChangeInFocus();
       
  4422             TryChangeModeL(ELatinUpper);
       
  4423             // delete it for support auto update to text-case
       
  4424             //SetFlag(EFlagSupressAutoUpdate);
       
  4425             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  4426             break;
       
  4427         case EAknCmdEditModeKorean:
       
  4428             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4429             HandleChangeInFocus();
       
  4430             TryChangeModeL(EHangul);
       
  4431             // delete it for support auto update to text-case
       
  4432             //SetFlag(EFlagSupressAutoUpdate);
       
  4433             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  4434             break;
       
  4435         case EChinFepCmdModeLatinLower:
       
  4436             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4437             HandleChangeInFocus();
       
  4438             TryChangeModeL(ELatinLower);
       
  4439             // delete it for support auto update to text-case
       
  4440             //SetFlag(EFlagSupressAutoUpdate);
       
  4441             iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  4442             break;
       
  4443         case EAknCmdEditModeNumber:
       
  4444         case EJapanFepCmdEditModeNumber:
       
  4445         case EChinFepCmdModeNumber:
       
  4446             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4447             HandleChangeInFocus();
       
  4448             if ( iLanguageCapabilities.iArabicIndicDigitsAllowed 
       
  4449                 || iLanguageCapabilities.iEasternArabicIndicDigitsAllowed 
       
  4450                 || iLanguageCapabilities.iIndicDigitsAllowed )
       
  4451                 {
       
  4452                 iLanguageCapabilities.iLocalDigitType = EDigitTypeWestern;
       
  4453                 }
       
  4454             TryChangeModeL(ENumber);
       
  4455             break;
       
  4456         case EAknCmdEditModeArabicIndicNumber:
       
  4457             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4458             HandleChangeInFocus();
       
  4459             iLanguageCapabilities.iLocalDigitType = EDigitTypeArabicIndic;
       
  4460             TryChangeModeL(ENativeNumber);
       
  4461             break;
       
  4462             /*For Eastern Arabic Numeric*/
       
  4463         case EAknCmdEditModeEasternArabicIndicNumber:
       
  4464             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4465             HandleChangeInFocus();
       
  4466             iLanguageCapabilities.iLocalDigitType = EDigitTypeEasternArabicIndic;
       
  4467             TryChangeModeL(ENativeNumber);
       
  4468             break;
       
  4469             /*for Hindi*/
       
  4470         case EAknCmdEditModeIndicNumber:
       
  4471             HandleChangeInFocus();
       
  4472             iLanguageCapabilities.iLocalDigitType = EDigitTypeDevanagari;
       
  4473             TryChangeModeL(ENativeNumber);
       
  4474             break;
       
  4475         case EChinFepCmdInstructions:
       
  4476             SetStopProcessFocus(ETrue);            
       
  4477             HandleChangeInFocus();
       
  4478             LaunchHelpTextQueryL();
       
  4479             SetStopProcessFocus(EFalse);            
       
  4480             break;
       
  4481         case EChinFepCmdModeZhuyinFind:
       
  4482             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4483             HandleChangeInFocus();
       
  4484             TryChangeModeL(EZhuyinFind);
       
  4485             break;
       
  4486         case EChinFepCmdModeStrokeFind:
       
  4487             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4488             HandleChangeInFocus();
       
  4489             TryChangeModeL(EStrokeFind);
       
  4490             break;
       
  4491 
       
  4492         // commands for western or common
       
  4493         case EJapanFepCmdMultitapPredictiveT9On:
       
  4494         case EAknCmdMultitapPredictiveT9On:
       
  4495 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4496         case EAknFepCmdPredActivate:
       
  4497 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4498             SetStopProcessFocus(ETrue, EFalse);
       
  4499             HandleChangeInFocus();
       
  4500 #ifdef RD_SCALABLE_UI_V2     
       
  4501         if( iFepFullyConstructed && iFepPluginManager)
       
  4502             {
       
  4503             iFepPluginManager->SetMenuState();            
       
  4504             }
       
  4505 #endif
       
  4506             if ( !iWesternPredictive )
       
  4507                 {
       
  4508                 LaunchConfirmationNoteL(R_AVKON_T9_ACTIVATED_NOTE);
       
  4509                 }
       
  4510             SetWesternPredictive(ETrue);
       
  4511             SetStopProcessFocus(EFalse);
       
  4512             TryChangeModeL(ELatin);
       
  4513             break;
       
  4514         case EAknCmdT9PredictiveT9Off:
       
  4515 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4516         case EAknFepCmdPredDeactivate:
       
  4517 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4518         SetStopProcessFocus(ETrue, EFalse);
       
  4519             HandleChangeInFocus();
       
  4520 #ifdef RD_SCALABLE_UI_V2     
       
  4521         if( iFepFullyConstructed && iFepPluginManager) 
       
  4522             {
       
  4523             iFepPluginManager->SetMenuState();            
       
  4524             }
       
  4525 #endif   
       
  4526             if (iMode != ELatin)
       
  4527                 {
       
  4528                 TryChangeModeL(ELatin);
       
  4529                 }
       
  4530             else
       
  4531                 {
       
  4532 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4533                 RemoveSuggestedAdvanceCompletionL();
       
  4534 #endif // RD_INTELLIGENT_TEXT_INPUT                	
       
  4535                 CommitInlineEditL();
       
  4536                 }
       
  4537 			if ( iWesternPredictive )
       
  4538                 {
       
  4539                 LaunchConfirmationNoteL(R_AVKON_T9_DEACTIVATED_NOTE);
       
  4540                 }
       
  4541             SetWesternPredictive(EFalse);
       
  4542             SetStopProcessFocus(EFalse);            
       
  4543             break;
       
  4544         case EAknCmdEditModeEnglish:
       
  4545         case EAknCmdEditModeAlpha:
       
  4546         case EJapanFepCmdEditModeAlpha:
       
  4547             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4548             HandleChangeInFocus();            
       
  4549             TryChangeModeL(ELatin);
       
  4550             iCaseMan->UpdateCase( ENullNaviEvent );
       
  4551             ClearFlag(EFlagSupressAutoUpdate);
       
  4552             break;
       
  4553         case EAknCmdEditModeLatinText:
       
  4554             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4555             HandleChangeInFocus();
       
  4556             TryChangeModeL(ELatinText);
       
  4557             ClearFlag(EFlagSupressAutoUpdate);
       
  4558             iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  4559             break;
       
  4560         case EAknCmdEditInsertSymbol:
       
  4561         case EAknCmdEditInsertSymbolJp:
       
  4562         case EAknFepSoftkeySymbol:
       
  4563         case EAknCmdEditInsertSmiley:
       
  4564             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  4565 #ifdef RD_SCALABLE_UI_V2            
       
  4566      if (iFepPluginManager && 
       
  4567         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
  4568          iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
  4569          iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)) 
       
  4570         {
       
  4571         iFepPluginManager->SetMenuState();     
       
  4572         }
       
  4573 
       
  4574 #endif //RD_SCALABLE_UI_V2             
       
  4575             SetStopProcessFocus(ETrue, EFalse);
       
  4576             HandleChangeInFocus();
       
  4577             if (aCommandId == EAknFepSoftkeySymbol)
       
  4578                 {               
       
  4579                 SetCcpuFlag(ECcpuStateCbaSymbol);
       
  4580                 }
       
  4581             // Show Thai specific SCT with Thai vowels and tonemarks
       
  4582             if ( (iLanguageCapabilities.iInputLanguageCode == ELangThai ) &&
       
  4583                  (iMode!=ENumber && iMode != ENativeNumber ) )
       
  4584                 {
       
  4585 #ifdef RD_INTELLIGENT_TEXT_INPUT                 	
       
  4586                 // if itut call Thai multitap HandleCommandL to Launch SCT	
       
  4587                 if(!iQwertyInputMode)
       
  4588                     {
       
  4589 #endif                    	
       
  4590                     TInt resourceId = 0;
       
  4591                     if (iAknFepThaiSCTSelector)
       
  4592                          {
       
  4593                         resourceId = iAknFepThaiSCTSelector->ThaiSCRResourceId(PreviousChar(),EPtiKeyStar);
       
  4594                         }
       
  4595                     LaunchSpecialCharacterTableL(resourceId, 
       
  4596                                                  aCommandId==EAknCmdEditInsertSymbol, 
       
  4597                                                  aCommandId==EAknCmdEditInsertSmiley);
       
  4598 #ifdef RD_INTELLIGENT_TEXT_INPUT                 	                    
       
  4599                     }
       
  4600                 else
       
  4601                     {
       
  4602                     CAknFepUIManagerWestern* westernUIManager = static_cast<CAknFepUIManagerWestern*>(FepUI());
       
  4603                     LaunchSpecialCharacterTableL(westernUIManager->ThaiSCTResourceId(static_cast<TChar>(PreviousChar()),EPtiKeyStar),
       
  4604                                                  aCommandId==EAknCmdEditInsertSymbol, 
       
  4605                                                  aCommandId==EAknCmdEditInsertSmiley);                    
       
  4606                     }
       
  4607 #endif                    
       
  4608                 }
       
  4609             else
       
  4610             {
       
  4611                 LaunchSpecialCharacterTableL(0, 
       
  4612                                              aCommandId==EAknCmdEditInsertSymbol, 
       
  4613                                              aCommandId==EAknCmdEditInsertSmiley);
       
  4614             }
       
  4615             SetStopProcessFocus(EFalse);
       
  4616             ClearCcpuFlag(ECcpuStateCbaSymbol);
       
  4617             break;
       
  4618         case EAknFepSoftkeyPrevious:
       
  4619             FepUI()->HandleCommandL(aCommandId);
       
  4620             break;
       
  4621         case EAknFepSoftkeySpell:
       
  4622             LaunchEditWordQueryL();
       
  4623             break;
       
  4624         case EAknCmdT9PredictiveInsertWord:
       
  4625             SetStopProcessFocus(ETrue);
       
  4626             HandleChangeInFocus();
       
  4627             LaunchInsertWordQueryL(KNullDesC, TCursorSelection(0,0));
       
  4628             SetStopProcessFocus(EFalse);
       
  4629 #ifdef RD_SCALABLE_UI_V2     
       
  4630         if( iFepFullyConstructed && iFepPluginManager)
       
  4631             {
       
  4632             iFepPluginManager->ResetMenuState();            
       
  4633             }
       
  4634 #endif             
       
  4635             break;
       
  4636         case EAknCmdT9PredictiveEditWord:
       
  4637             SetStopProcessFocus(ETrue);
       
  4638             HandleChangeInFocus();
       
  4639 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4640                 RemoveSuggestedAdvanceCompletionL();
       
  4641 #endif // RD_INTELLIGENT_TEXT_INPUT   
       
  4642             LaunchEditWordQueryL();
       
  4643             SetStopProcessFocus(EFalse);
       
  4644 #ifdef RD_SCALABLE_UI_V2     
       
  4645             if( iFepFullyConstructed && iFepPluginManager )
       
  4646                 {
       
  4647                 iFepPluginManager->ResetMenuState();            
       
  4648                 }
       
  4649 #endif 
       
  4650             break;
       
  4651         case EAknCmdT9PredictiveMatches:
       
  4652             SetStopProcessFocus(ETrue,EFalse);
       
  4653             LaunchMatchesPopupListL();
       
  4654             SetStopProcessFocus(EFalse);
       
  4655             break;
       
  4656 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  4657         case EAknCmdPredictiveAutoWord:
       
  4658              if ( !iIsAutoCompleteOn )
       
  4659                 {
       
  4660                 SetStopProcessFocus(ETrue);
       
  4661                 LaunchConfirmationNoteL(R_AVKON_PREDICTIVE_AUTOCOMPLETION_ACTIVATED_NOTE);
       
  4662                 SetStopProcessFocus(EFalse);
       
  4663                 }
       
  4664              iIsAutoCompleteOn = ETrue;      
       
  4665          	 iSharedDataInterface->SetPredictiveTextAutoCompleteOn();  			                 	 
       
  4666 #ifdef  RD_SCALABLE_UI_V2       	 
       
  4667             if(iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
  4668                 {
       
  4669                 SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4670                 HandleChangeInFocus();
       
  4671                 }
       
  4672 #endif
       
  4673 	 		 UpdateIndicators();
       
  4674         	 break;
       
  4675         case EAknCmdPredictiveNormal:
       
  4676              if ( iIsAutoCompleteOn )
       
  4677                 {
       
  4678                 SetStopProcessFocus(ETrue);
       
  4679                 LaunchConfirmationNoteL(R_AVKON_PREDICTIVE_AUTOCOMPLETION_DEACTIVATED_NOTE);
       
  4680                 SetStopProcessFocus(EFalse);
       
  4681                 }
       
  4682          	 iIsAutoCompleteOn = EFalse;
       
  4683          	 iSharedDataInterface->ResetPredictiveTextAutoCompleteOn();        	 
       
  4684         	 UpdateIndicators();
       
  4685         	 break;
       
  4686 #endif
       
  4687         case EAknCmdInputLanguage:
       
  4688 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4689         case EAknFepCmdPredInputLanguage:
       
  4690 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4691             SetStopProcessFocus(ETrue, EFalse);
       
  4692             HandleChangeInFocus();
       
  4693 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4694 #ifdef FF_DUAL_LANGUAGE_SUPPORT 
       
  4695             	// Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  4696                 // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  4697                 if(iKeyboardType == EPtiKeyboard12Key || iKeyboardType == EPtiKeyboardHalfQwerty )
       
  4698                     LaunchDualLanguageSettingDialogL();
       
  4699                 else 
       
  4700 					{ 
       
  4701 					LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);		            
       
  4702 		            iStopProcessFocus = EFalse; 
       
  4703 					}             
       
  4704 #else // FF_DUAL_LANGUAGE_SUPPORT
       
  4705             LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);
       
  4706             //HandleChangeInFocus();
       
  4707             iStopProcessFocus = EFalse;
       
  4708 #endif // FF_DUAL_LANGUAGE_SUPPORT
       
  4709 #else            
       
  4710             LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);
       
  4711             HandleChangeInFocus();
       
  4712             iStopProcessFocus = EFalse;
       
  4713 #endif
       
  4714             break;
       
  4715         case EAknEditMenuCmdCutText:
       
  4716              StartCcpuModeL(EFalse);
       
  4717              if (WesternPredictive())
       
  4718                 {                
       
  4719                 // Remove underlining from predicted word when focus is re-gained.
       
  4720                 SetCcpuFlag(ECcpuStateUncommitWhenFocused);                 
       
  4721                 }                                     
       
  4722              SetCcpuFlag(ECcpuStateIgnoreNextFocusChange);                            
       
  4723              SetCcpuFlag(ECcpuStateEdwinInSelectionMode);                       
       
  4724              break;            
       
  4725         case EAknEditMenuCmdCopyText:                               
       
  4726              StartCcpuModeL(ETrue);
       
  4727              if (WesternPredictive())
       
  4728                 {                
       
  4729                 // Remove underlining from predicted word when focus is re-gained.
       
  4730                 SetCcpuFlag(ECcpuStateUncommitWhenFocused);                 
       
  4731                 }                        
       
  4732              SetCcpuFlag(ECcpuStateIgnoreNextFocusChange);               
       
  4733              SetCcpuFlag(ECcpuStateEdwinInSelectionMode);                
       
  4734              break;
       
  4735         case EAknFepSoftkeyStartCopy:
       
  4736         case EAknFepSoftkeyStartCut:        
       
  4737              {
       
  4738              ResetCcpuFlags();
       
  4739              if (aCommandId == EAknFepSoftkeyStartCopy)
       
  4740                 {
       
  4741                 SetCcpuFlag(ECcpuStateCopy);                
       
  4742                 }
       
  4743              else
       
  4744                 {
       
  4745                 SetCcpuFlag(ECcpuStateCut);
       
  4746                 }
       
  4747                 
       
  4748              __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
  4749                             AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  4750                  
       
  4751             TBool update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
  4752             update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow, 
       
  4753                                       R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  4754             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ); 
       
  4755             if (update)
       
  4756                 {
       
  4757                 iUiInterface->DrawSoftkeysNow();
       
  4758                 }                           
       
  4759              }
       
  4760              break;   
       
  4761         case EEikCmdEditCopy:
       
  4762         case EEikCmdEditCut:
       
  4763             {
       
  4764 #ifdef RD_SCALABLE_UI_V2            
       
  4765      if (iFepPluginManager && 
       
  4766         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
  4767          iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
  4768          iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)) 
       
  4769         {
       
  4770         iFepPluginManager->SetMenuState(EFalse);     
       
  4771         }
       
  4772 
       
  4773 #endif //RD_SCALABLE_UI_V2             
       
  4774             SetStopProcessFocus(ETrue, EFalse);
       
  4775             HandleCopyCutEventL(aCommandId);
       
  4776             SetStopProcessFocus(EFalse);            
       
  4777             }
       
  4778             break;
       
  4779         case EEikCmdEditPaste:
       
  4780            	{
       
  4781            	// We have a hindi character in clipboard which can form ligature with the existing text
       
  4782            	// if pasted. While the input language is English, the cursor aligmment check would not happen.
       
  4783            	// When selecting Options->Paste, the Fep context at this point is for the menu.
       
  4784            	// iInputCapabilities for editor context is retrived from CCoeEnv and is restored back
       
  4785            	// after doing the operation, else FepAwareTextEditor will be true in menu context.
       
  4786            	if ( (!BidiCursorRequired()) && (!WesternPredictive()) )
       
  4787            		{
       
  4788 	        	TCoeInputCapabilities origInputCapabilities = iInputCapabilities;
       
  4789 	        
       
  4790 	        	CCoeEnv* coeEnv = CCoeEnv::Static();
       
  4791 	        	iInputCapabilities = static_cast<const CCoeAppUi*>(coeEnv->AppUi())->InputCapabilities();
       
  4792         	
       
  4793         		if( !(iInputCapabilities.SupportsSecretText()) )		        
       
  4794 		        	{
       
  4795 		    	    DoCursorDirectionCheckL();
       
  4796 			        }	
       
  4797     	       	iInputCapabilities = origInputCapabilities;
       
  4798 	           	}
       
  4799            	}     
       
  4800         	break;
       
  4801             
       
  4802         case EAknCmdEditMenuSctSelected:
       
  4803             {
       
  4804             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  4805             HandleChangeInFocus();  // to re-establish contact with editor
       
  4806 
       
  4807             TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
  4808             for ( TInt ii = 0; ii < iSctEditChars->Length(); ii++)
       
  4809                 {
       
  4810                 charAsDesc[0]=(TText) (*iSctEditChars)[ii];
       
  4811                 if (charAsDesc[0] == TText(0x000A) // 0x000A is line feed
       
  4812                  || charAsDesc[0] == CEditableText::EParagraphDelimiter) 
       
  4813                     {
       
  4814                     // This is line feed character. Post it to editor and let it decide
       
  4815                     // if it is valid.
       
  4816                     if (!(iAknEditorFlags & EAknEditorFlagFindPane) && iSctEditChars->Length() == 1)                              
       
  4817                         {
       
  4818                         SimulateKeyEventL(EKeyEnter);
       
  4819                         SimulateKeyEventL(EKeyF19); // Asyncronous case update                                                                                  
       
  4820                         }
       
  4821                     }                                                        
       
  4822                 else
       
  4823                     {
       
  4824                     if (CharIsValidInEditor(charAsDesc[0]))
       
  4825                     {
       
  4826                     TCursorSelection cursorSelection(0,0);
       
  4827                     if ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) && 
       
  4828                                     iMode == ELatin && !WesternPredictive())
       
  4829                         {
       
  4830                         TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  4831                         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  4832                         if (iUncommittedText.iCursorPos < edSize && iUncommittedText.Length() == 0)
       
  4833                             {
       
  4834                             cursorSelection = TCursorSelection(iUncommittedText.iCursorPos + 1, 
       
  4835                                                                iUncommittedText.iAnchorPos);
       
  4836                             }
       
  4837                         }
       
  4838                         
       
  4839                     if (EditorHasFreeSpace())
       
  4840                         {
       
  4841                         InsertTextFromDialogL(charAsDesc, cursorSelection);
       
  4842                         }
       
  4843                                            
       
  4844                     }
       
  4845                   } 
       
  4846                  
       
  4847                 }
       
  4848             } 
       
  4849             break;
       
  4850         case EAknCmdTaskSwapper:
       
  4851             SendEventsToPluginManL( EPluginFaseSwap, ETrue );
       
  4852             break;
       
  4853             
       
  4854         case EAknCmdEditMenuClose:
       
  4855             {
       
  4856             // Handle destruction of menu
       
  4857             StopDisplayingMenuBar();     
       
  4858             }            
       
  4859         break;
       
  4860 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4861         // Predictive QWERTY (XT9) changes ---->
       
  4862          case EAknFepCmdPredMatches:
       
  4863          {
       
  4864          	HandleChangeInFocus();  // to re-establish contact with editor
       
  4865 	        // Focus current active word in list ---->
       
  4866 	        TInt wordToFocus;
       
  4867 	        iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &wordToFocus );
       
  4868 	        iSListLaunchedFromMenu = ETrue;
       
  4869 	        TKeyEvent candLaunch = {EKeyDownArrow, EStdKeyDownArrow, 0, 0};
       
  4870 			CEikonEnv::Static()->WsSession().SimulateKeyEvent(candLaunch);
       
  4871 	        //LaunchCandidatePopupListL( wordToFocus );
       
  4872 	       }
       
  4873 	        break;
       
  4874         case EAknFepCmdPredSettings:
       
  4875         	LaunchPredictiveSettingDialogL();
       
  4876         	break;
       
  4877         /*
       
  4878 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  4879 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  4880 	    This is For Insert Word Functionality*/	
       
  4881         case EAknEditMenuCmdInsertWord:
       
  4882         	HandleChangeInFocus();
       
  4883             LaunchInsertWordQueryL(KNullDesC, TCursorSelection(0,0));
       
  4884         	break;
       
  4885 #ifdef __USER_DICTIONARY_EDITING__ 
       
  4886         case EAknFepCmdPredEditUserDictionary:
       
  4887             if ( IsAutoCompleteOn() )
       
  4888                 {
       
  4889                 HandleChangeInFocus();
       
  4890                 RemoveSuggestedAdvanceCompletionL();
       
  4891                 }
       
  4892             UiInterface()->LaunchUserDictEditDialogL();
       
  4893             break;
       
  4894 #endif //__USER_DICTIONARY_EDITING__ 
       
  4895         
       
  4896         case EAknFepCmdPredHelp:
       
  4897 	        // Help ID:PREDINPUT_HLP_INPUT
       
  4898 			{					
       
  4899             const TInt KArrayGranularity = 3;
       
  4900             CArrayFix<TCoeHelpContext>* contexts =
       
  4901                     new (ELeave) CArrayFixFlat<TCoeHelpContext>( KArrayGranularity );
       
  4902 	    	CleanupStack::PushL ( contexts );
       
  4903 	    	TUid appuid = { 0x100058EC };
       
  4904 	    	contexts->AppendL( TCoeHelpContext( appuid, KFEPPREDINPUT_HLP_INPUT ) );
       
  4905 	    	CleanupStack::Pop( contexts );
       
  4906 	    	HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), contexts );			
       
  4907 			}
       
  4908 	        break;
       
  4909        // Predictive QWERTY (XT9) changes <----
       
  4910 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4911         // add for phrase creation user db view.
       
  4912         case EAknCmdUserDBDlg:
       
  4913             {
       
  4914             HandleChangeInFocus();
       
  4915             LaunchUserDBDlgL();
       
  4916            }            
       
  4917         break;
       
  4918         case EPenInputCmdPreviewOn:
       
  4919             {
       
  4920             iSharedDataInterface->SetFepShowVkbPreviewStatus(KTouchInputPreviewOn);
       
  4921             SendEventsToPluginManL(EPluginPreview, KTouchInputPreviewOn);  
       
  4922             }
       
  4923         break;
       
  4924         case EPenInputCmdPreviewOff:
       
  4925             {
       
  4926             iSharedDataInterface->SetFepShowVkbPreviewStatus(KTouchInputPreviewOff);
       
  4927             SendEventsToPluginManL(EPluginPreview, KTouchInputPreviewOff);    
       
  4928             }
       
  4929         break;
       
  4930         case EPenInputCmdRecognitionWithDictionary:
       
  4931             {
       
  4932             SetStopProcessFocus(ETrue);
       
  4933             HandleChangeInFocus();
       
  4934             LaunchRecognitionWithDictionaryPopupListL();
       
  4935             HandleChangeInFocus();
       
  4936             iStopProcessFocus = EFalse;
       
  4937             }
       
  4938         break;
       
  4939         default:
       
  4940             break;
       
  4941         }
       
  4942         
       
  4943         
       
  4944     StopDisplayingMenuBar();
       
  4945     }
       
  4946 
       
  4947 void CAknFepManager::SetEmphasis(CBase* /*aMenuControl*/,TBool aEmphasis)
       
  4948     {
       
  4949     if (aEmphasis)
       
  4950         { // opening main menu pane
       
  4951         SetFlag(EFlagMenuPaneVisible);
       
  4952         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  4953             {
       
  4954             SetFlag(EFlagInlineEditInBackground);
       
  4955             }
       
  4956         }
       
  4957     else
       
  4958         {
       
  4959 		// The pointer to be cleared when the callback is received on leaving the focus from the menu pane.
       
  4960 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  4961         iOptionsMenuBar = NULL;
       
  4962 #endif
       
  4963         ClearFlag(EFlagMenuPaneVisible | EFlagRemoveMatchesMenuItem | EFlagInlineEditInBackground);
       
  4964         }
       
  4965     }
       
  4966 
       
  4967 void CAknFepManager::DynInitMenuBarL(TInt aResourceId, CAknFepUiInterfaceMenuBar* aMenuBar)
       
  4968     {
       
  4969     if (iFepFullyConstructed && IsFlagSet(EFlagLaunchEditMenu))
       
  4970         {
       
  4971         aMenuBar->ReplaceAllMenuPanes(R_AVKON_EDIT_MODE_MENU);
       
  4972         }
       
  4973         
       
  4974 #ifdef RD_SCALABLE_UI_V2        
       
  4975     if (iFepFullyConstructed &&
       
  4976         aResourceId == R_AVKON_PENINPUT_OPTION_MENU_BAR)
       
  4977         {
       
  4978         aMenuBar->ReplaceAllMenuPanes(R_AVKON_TOUCH_TOUCHINPUT_MENU);
       
  4979         }
       
  4980 #endif //RD_SCALABLE_UI_V2        
       
  4981         
       
  4982     }
       
  4983 
       
  4984 #ifdef RD_SCALABLE_UI_V2
       
  4985 void CAknFepManager::DynInitTouchMenuPaneL(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  4986     {
       
  4987     if ( !iFepFullyConstructed )
       
  4988         {
       
  4989         return;
       
  4990         }
       
  4991 
       
  4992 
       
  4993     if (iFepManState != EAknFepStateNull &&
       
  4994         iInputCapabilities.FepAwareTextEditor() &&
       
  4995         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  4996         {
       
  4997         // 'Input language' menu item on option menu isn't supported in Japanese variant.
       
  4998         if (!IsFeatureSupportedJapanese())
       
  4999             {
       
  5000             // Insert 'Input language' item to incoming menu if editor is active on screen and
       
  5001             // menu contains 'Help' or 'Exit' item.
       
  5002             if (!IsOnlyNumericPermitted())
       
  5003                 {
       
  5004                 TInt helpIndex;
       
  5005                 if (aMenuPane->MenuItemExists(EAknCmdHelp, helpIndex) ||
       
  5006                     aMenuPane->MenuItemExists(EAknCmdExit, helpIndex))
       
  5007                     {
       
  5008                     AddInputLanguageItemL(aMenuPane, helpIndex);
       
  5009                     }
       
  5010                 }
       
  5011             }
       
  5012         }
       
  5013 
       
  5014     TInt index;
       
  5015     if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5016 	    {
       
  5017 		aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);	   
       
  5018 	    }
       
  5019 
       
  5020     ClearFlag(EFlagLaunchEditMenu);
       
  5021             
       
  5022     DimInputmodeTouchMenuItems(aMenuPane);
       
  5023     }
       
  5024 #endif //RD_SCALABLE_UI_V2
       
  5025 void CAknFepManager::DynInitMenuPaneL(TInt aResourceId, CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5026     {
       
  5027     if ( !iFepFullyConstructed )
       
  5028         {
       
  5029         return;
       
  5030         }
       
  5031 
       
  5032 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  5033     CAknEdwinState* editorState = NULL;
       
  5034     if (iInputCapabilities.FepAwareTextEditor())
       
  5035         {
       
  5036         editorState = EditorState();
       
  5037         }
       
  5038 
       
  5039     if (editorState)
       
  5040         {
       
  5041         iOptionsMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  5042         }
       
  5043 #endif    
       
  5044     
       
  5045     SetCcpuFlag(ECcpuStateIgnoreNextEdwinSyncEvent);
       
  5046 
       
  5047     if (iFepManState != EAknFepStateNull &&
       
  5048         iInputCapabilities.FepAwareTextEditor() &&
       
  5049         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5050         {
       
  5051         // 'Input language' menu item on option menu isn't supported in Japanese variant.
       
  5052         if (!IsFeatureSupportedJapanese())
       
  5053             {
       
  5054             // Insert 'Input language' item to incoming menu if editor is active on screen and
       
  5055             // menu contains 'Help' or 'Exit' item.
       
  5056             //Also, no need for writing language/ITI options in telephony's dialer
       
  5057             if ( (RProcess().SecureId().iId != KPhoneSecureId) && !IsOnlyNumericPermitted() )
       
  5058                 {
       
  5059 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
  5060                 //This method gets called multiple times - first before the help and exit
       
  5061                 //commands are populated and finally after these items are added.
       
  5062                 //So if we have already added the input options menu and/or writing language menu,
       
  5063                 //remove it. It will get added again to the correct place with the below code.
       
  5064                 //No need to handle following menu types here.
       
  5065                 if ( !( R_AVKON_EDIT_MODE_MENU == aResourceId || 
       
  5066                         R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU == aResourceId ||
       
  5067                         R_AVKON_PREDICTIVE_TEXT_MENU_T9 == aResourceId ||
       
  5068                         R_AVKON_INPUT_MODE_SUB_MENU == aResourceId ||
       
  5069                         R_AKNFEP_EDIT_SUBMENU == aResourceId ||
       
  5070                         R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId ) 
       
  5071                 // Add this condition for adding "input options" into the option menu of FSQ.
       
  5072                         || ( R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId
       
  5073                              && iFepPluginManager
       
  5074                              && iFepPluginManager->IsSupportITIOnFSQ() )
       
  5075                         )                        
       
  5076                     {
       
  5077                     FindAndRemoveInputOptionsMenuItemL( aMenuPane );
       
  5078                     FindAndRemoveEditSubMenuItemL (aMenuPane);
       
  5079                     AddInputOptionsMenuItemL( aMenuPane );
       
  5080                     }                                	        	
       
  5081 #else
       
  5082                 TInt helpIndex;
       
  5083 		if ( aMenuPane->MenuItemExists(EAknCmdHelp, helpIndex) ||
       
  5084                      aMenuPane->MenuItemExists(EAknCmdExit, helpIndex) )
       
  5085                     {
       
  5086                     AddInputLanguageItemL(aMenuPane, helpIndex);
       
  5087                     }
       
  5088                        	
       
  5089 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5090                 }
       
  5091             }
       
  5092 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5093         if ( IsChineseInputLanguage() && 
       
  5094                 ( iKeyboardType == EPtiKeyboardQwerty4x10 ||
       
  5095                 iKeyboardType == EPtiKeyboardQwerty3x11 ) )
       
  5096             {
       
  5097             // the follow added for phrase creation
       
  5098             TInt iptlanguage;
       
  5099             if ( !iIsUserdbdlgActive )
       
  5100                 {
       
  5101                 aMenuPane->MenuItemExists( EAknCmdInputLanguage, iptlanguage );
       
  5102                 AddUserDBDlgItemL( aMenuPane, iptlanguage );
       
  5103                 }
       
  5104             }
       
  5105 #endif
       
  5106 
       
  5107         if (!(aResourceId == R_AVKON_EDIT_MODE_MENU ||
       
  5108             aResourceId == R_AVKON_TOUCH_TOUCHINPUT_MENU ||
       
  5109             aResourceId == R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU))
       
  5110             {
       
  5111             AddEditSubmenuL(aMenuPane);
       
  5112             }
       
  5113         }
       
  5114 		
       
  5115 		//HWR Hindi, Training application is not available,
       
  5116         //Disable Menu option
       
  5117         if(aResourceId == R_AVKON_TOUCH_TOUCHINPUT_MENU && 
       
  5118         	iLanguageCapabilities.iInputLanguageCode == ELangHindi)
       
  5119         	{
       
  5120         	aMenuPane->SetItemDimmed(EPenInputCmdHwrTraining, ETrue);
       
  5121         	}
       
  5122     TInt index;
       
  5123     if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5124 	    {
       
  5125 		aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);	   
       
  5126 	    }
       
  5127 #ifdef RD_SCALABLE_UI_V2
       
  5128     TInt oldPermitModes = -1;
       
  5129     if (R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId )
       
  5130         {
       
  5131         oldPermitModes = iPermittedInputModes;
       
  5132         
       
  5133         if( iFepPluginManager != NULL )
       
  5134             {
       
  5135             iPermittedInputModes = iFepPluginManager->PreviousPermitMode();
       
  5136             }
       
  5137         }
       
  5138 
       
  5139     iFepPluginManager->InitMenuPaneL( iRememberEditorState, aMenuPane, aResourceId );
       
  5140     if (oldPermitModes != -1)
       
  5141         {
       
  5142         iPermittedInputModes = oldPermitModes;    
       
  5143         }
       
  5144 #endif //  RD_SCALABLE_UI_V2      
       
  5145     switch (aResourceId)
       
  5146         {
       
  5147         case R_AVKON_TOUCHINPUT_PREVIEW:
       
  5148             {
       
  5149             InitPreviewMenuPane(aMenuPane);     
       
  5150             } 
       
  5151         break;
       
  5152         case R_AVKON_EDIT_MODE_MENU:
       
  5153         case R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU:
       
  5154             {
       
  5155             ClearFlag(EFlagLaunchEditMenu);
       
  5156             
       
  5157    		  //call comes here when edit key or '*' is pressed and displays avkon edit menu            
       
  5158 		  //moving only the essential condition checks in EditSubmenuInUse() here
       
  5159 		  //no need of checking iSharedDataInterface->EditSubmenuInUse() because for devices with edit key
       
  5160 		  //this would return 0 and would not populate CUT and COPY option
       
  5161 
       
  5162         	TBool tempFlag = ETrue;
       
  5163 	        if ( ( ( RProcess().SecureId().iId == KPhoneSecureId ) && (iQwertyInputMode) ) ||
       
  5164 	             ( ExtendedInputCapabilities() & 
       
  5165                  CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff)
       
  5166 	        	  
       
  5167 	           )
       
  5168 	        	{
       
  5169 	        	tempFlag = EFalse;         		
       
  5170 	        	}
       
  5171 
       
  5172             if (tempFlag)
       
  5173                 {
       
  5174                 TInt posit(0);
       
  5175                     
       
  5176                 if (!(iAknEditorFlags & EAknEditorFlagFindPane) &&
       
  5177                 	iInputCapabilities.FepAwareTextEditor() &&
       
  5178                     aMenuPane->MenuItemExists(EEikCmdEditCut, posit) &&
       
  5179                     !IsOnlyNumericPermitted() 
       
  5180                     )
       
  5181                     { 
       
  5182                     if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() > 0 )
       
  5183                     	{
       
  5184 						if (iRememberEditorState && iRememberEditorState->CcpuState() &&
       
  5185 							!iRememberEditorState->CcpuState()->CcpuCanCopy()&& 
       
  5186 							PluginInputMode() != EPluginInputModeItut )                      
       
  5187 							{                                                       
       
  5188 							TBuf<KMaxFileName> titleStr;
       
  5189 							StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_MENU_CUT_TEXT);                          
       
  5190 																
       
  5191 							CAknFepUiInterfaceMenuPane::SItemData itemData;
       
  5192 						
       
  5193 							itemData.iCommandId = EAknEditMenuCmdCutText;
       
  5194 							itemData.iCascadeId = 0;                        
       
  5195 							if (titleStr.Length())
       
  5196 								{
       
  5197 								itemData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1));                                                
       
  5198 								}
       
  5199 							itemData.iFlags = 0;                        
       
  5200 							aMenuPane->InsertMenuItemL(itemData, posit);            
       
  5201 											
       
  5202 							titleStr.Zero();                                            
       
  5203 							itemData.iText.Zero();
       
  5204 							StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_MENU_COPY_TEXT);
       
  5205 							
       
  5206 							itemData.iCommandId = EAknEditMenuCmdCopyText;                      
       
  5207 							if (titleStr.Length())
       
  5208 								{
       
  5209 								itemData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1));                                                
       
  5210 								}
       
  5211 							aMenuPane->InsertMenuItemL(itemData, posit);                                                    
       
  5212 							}
       
  5213 						else //Hack for browser in case there are some text already selected
       
  5214 							{
       
  5215 							 if (iRememberEditorState && iRememberEditorState->CcpuState() )
       
  5216 								 {
       
  5217 								  if(iRememberEditorState->CcpuState()->CcpuCanPaste())
       
  5218 									  aMenuPane->SetItemDimmed(EEikCmdEditPaste,EFalse);
       
  5219 								  if(iRememberEditorState->CcpuState()->CcpuCanCopy())
       
  5220 									  aMenuPane->SetItemDimmed(EEikCmdEditCopy,EFalse);
       
  5221 								  if(iRememberEditorState->CcpuState()->CcpuCanCut())
       
  5222 									  aMenuPane->SetItemDimmed(EEikCmdEditCut,EFalse);
       
  5223 								 }
       
  5224 							 }
       
  5225                     	}
       
  5226                     //if the document size is 0 and there are items in clipboard then dislay Paste item
       
  5227                     if ( iRememberEditorState && iRememberEditorState->CcpuState() &&
       
  5228                          iRememberEditorState->CcpuState()->CcpuCanPaste())
       
  5229                         aMenuPane->SetItemDimmed(EEikCmdEditPaste,EFalse);
       
  5230                     
       
  5231                     } 
       
  5232                 
       
  5233                 }                       
       
  5234             
       
  5235             DimInputmodeMenuItems(aMenuPane);
       
  5236 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5237             //Is this an edit menu launched for a western language?
       
  5238             if ( R_AVKON_EDIT_MODE_MENU == aResourceId && !IsChineseInputLanguage() 
       
  5239                     && ELangJapanese != iLanguageCapabilities.iInputLanguageCode )
       
  5240                 {
       
  5241                 //If this is edit menu (launched from '*' or edit key) and predictive input is allowed,
       
  5242                     //we need to remove "Input language" and add "Input options" menu item. 
       
  5243                 if (!IsOnlyNumericPermitted() && IsLanguageSupportPrediction() && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  5244                     {
       
  5245                     TInt menuitemPos(0);
       
  5246                     if(aMenuPane->MenuItemExists(EAknCmdEditInsertSmiley,menuitemPos)) // insert after smiley if exist
       
  5247                         {
       
  5248                         AddPredictiveModeEditMenuL(aMenuPane,menuitemPos+1);
       
  5249                         }
       
  5250                     else if(aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol,menuitemPos)) // insert after smybol if exist
       
  5251                         {
       
  5252                         AddPredictiveModeEditMenuL(aMenuPane,menuitemPos+1);
       
  5253                         }
       
  5254                     }
       
  5255                 }
       
  5256 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5257 
       
  5258             }
       
  5259             break;
       
  5260                         
       
  5261         case R_AVKON_PREDICTIVE_TEXT_MENU_T9:
       
  5262             {
       
  5263             if (iMode != ELatin)
       
  5264                 {
       
  5265                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveInsertWord, ETrue);
       
  5266                 }
       
  5267             if (!IsFlagSet(EFlagInlineEditInBackground))
       
  5268                 {
       
  5269                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveMatches, ETrue);
       
  5270                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveEditWord, ETrue);
       
  5271                 }
       
  5272             else if (IsFlagSet(EFlagRemoveMatchesMenuItem))
       
  5273                 {
       
  5274                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveMatches, ETrue);
       
  5275                 }
       
  5276             break;
       
  5277             }
       
  5278         case R_AVKON_INPUT_MODE_SUB_MENU:
       
  5279             {
       
  5280             if (IsChineseInputLanguage())
       
  5281                 {
       
  5282                 DoChineseSubMenu(aMenuPane);
       
  5283                 }
       
  5284             break;
       
  5285         case R_AKNFEP_EDIT_SUBMENU:
       
  5286             DisableEditSubmenuItems(aMenuPane);
       
  5287             break;
       
  5288             }
       
  5289 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5290             // Predictive QWERTY (XT9) changes ---->
       
  5291         case R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU:
       
  5292         	{
       
  5293             	// This part of code fixing TSW Errors :STAA-7GZE5W
       
  5294             	//									   :STAA-7GZEBX 
       
  5295             	// "Edit word" option is not available under edit menu in ITU-T mode.
       
  5296             	// "Insert word" Should not be available QWERTY mode.
       
  5297             //TSW: AKSS-7P87XG
       
  5298             //TSW: AKSS-7P88Wf	
       
  5299           	if (IsKoreanInputLanguage() || 
       
  5300                     iPtiEngine->CurrentLanguage()->LanguageCode() == ELangPrcChinese || 
       
  5301                     iPtiEngine->CurrentLanguage()->LanguageCode() == ELangTaiwanChinese || 
       
  5302                     iPtiEngine->CurrentLanguage()->LanguageCode() == ELangHongKongChinese  )
       
  5303           		{
       
  5304           		// No text prediction for korean.
       
  5305           		aMenuPane->SetItemDimmed(EAknFepCmdPredActivate, ETrue );
       
  5306           		aMenuPane->SetItemDimmed(EAknFepCmdPredDeactivate,ETrue );
       
  5307                 aMenuPane->SetItemDimmed( EAknFepCmdPredSettings, ETrue );
       
  5308           		}
       
  5309           	else 
       
  5310                 {
       
  5311                 aMenuPane->SetItemDimmed( EAknFepCmdPredSettings, EFalse );
       
  5312                 if(iSharedDataInterface->PredictiveTextOn())
       
  5313                     {
       
  5314                     aMenuPane->SetItemDimmed( EAknFepCmdPredActivate, ETrue );					
       
  5315                     }
       
  5316                 else
       
  5317                     {
       
  5318                     aMenuPane->SetItemDimmed(EAknFepCmdPredDeactivate,ETrue ); 
       
  5319                     }	
       
  5320                 }
       
  5321         	} 
       
  5322           break;
       
  5323             
       
  5324 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5325         default:
       
  5326             break;
       
  5327         }
       
  5328 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5329 	/*
       
  5330     This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  5331     "Matches" and "insert word" options are not available under Edit Menu.
       
  5332     This is To make visible/invisible the Insert Word in Optios menu & Edit Menu*/
       
  5333     iIsLastResourceEditMenu = aResourceId;
       
  5334 #endif  
       
  5335     }
       
  5336 
       
  5337 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5338 void CAknFepManager::FindAndRemoveInputOptionsMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5339     {
       
  5340     //Logic : 
       
  5341     //Loop through each item in menu pane and check if the data
       
  5342     //CEikMenuPaneItem::SData::iCascadeId == R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU
       
  5343     //or if CEikMenuPaneItem::SData::iCommandId == EAknCmdInputLanguage
       
  5344     //If so, delete that item.
       
  5345     TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5346     CEikMenuPane* menuPane = aMenuPane->GetMenuPane();
       
  5347     for (TInt index(0); index < numOfMenuItems ; ++index )
       
  5348         {
       
  5349         CEikMenuPaneItem::SData itemData = menuPane->ItemDataByIndexL( index );
       
  5350         if ( itemData.iCascadeId == R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU ||
       
  5351              itemData.iCommandId == EAknCmdInputLanguage ||
       
  5352              itemData.iCascadeId == R_AVKON_INPUT_MODE_SUB_MENU ||
       
  5353            ( IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode() && 
       
  5354              itemData.iCommandId == EChinFepCmdModeCangJieOption ) )
       
  5355             { 
       
  5356             menuPane->DeleteBetweenMenuItems( index, index );
       
  5357             //Assumption - there can only be one such item in the menu pane
       
  5358             //Hence we can return without going through the remaining items
       
  5359             numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5360             index--;
       
  5361             }
       
  5362         }
       
  5363     }
       
  5364 
       
  5365 void CAknFepManager::FindAndRemoveEditSubMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5366     {
       
  5367     //Logic : 
       
  5368     //Loop through each item in menu pane and check if the data
       
  5369     //CEikMenuPaneItem::SData::iCascadeId == R_AKNFEP_EDIT_SUBMENU
       
  5370     //If so, delete that item.
       
  5371     TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5372     CEikMenuPane* menuPane = aMenuPane->GetMenuPane();
       
  5373     for (TInt index(0); index < numOfMenuItems ; ++index )
       
  5374         {
       
  5375         CEikMenuPaneItem::SData itemData = menuPane->ItemDataByIndexL( index );
       
  5376         if ( itemData.iCascadeId == R_AKNFEP_EDIT_SUBMENU )
       
  5377             {
       
  5378             menuPane->DeleteBetweenMenuItems( index, index );
       
  5379             //Assumption - there can only be one such item in the menu pane
       
  5380             //Hence we can return without going through the remaining items
       
  5381             return;
       
  5382             }
       
  5383         }
       
  5384     }
       
  5385 
       
  5386 void CAknFepManager::AddInputOptionsMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5387     {
       
  5388     //Logic:
       
  5389     //Appropriate location is :
       
  5390     //  if Avkon Help command exists, then immediately above it
       
  5391     //  else if Avkon Exit command exists, then immediately above it
       
  5392     //  else if there are 3 or more items in the Options menu, then 3rd from last
       
  5393     //  else it is the last item. 
       
  5394     TInt posToInsertItem( 0 );
       
  5395     //MenuItemExists() will return the index of the item in 2nd parameter
       
  5396     //But if item is not found, it is returning the total number of items.
       
  5397     if ( ( aMenuPane->MenuItemExists(EAknCmdHelp, posToInsertItem) ) ||
       
  5398          ( aMenuPane->MenuItemExists(EAknCmdExit, posToInsertItem) ) )
       
  5399         {
       
  5400         //do nothing - we already have posToInsertItem with required value 
       
  5401         }
       
  5402     else 
       
  5403         {
       
  5404         TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5405         if ( numOfMenuItems > 2 )
       
  5406             {
       
  5407             //We should add the new item as third from last, after ignoring
       
  5408             //any dimmed items in the menu pane
       
  5409             TInt numOfUnDimmedItems(0);
       
  5410             //loop from bottom for better performance 
       
  5411             for (TInt index(numOfMenuItems-1); index >= 0 ; --index )
       
  5412                 {
       
  5413                 CEikMenuPaneItem::SData itemData = aMenuPane->GetMenuPane()->ItemDataByIndexL( index );
       
  5414                 if ( !(itemData.iFlags & EEikMenuItemDimmed) )
       
  5415                     {
       
  5416                     ++numOfUnDimmedItems;
       
  5417                     }
       
  5418                 if ( numOfUnDimmedItems == 2 )
       
  5419                     {
       
  5420                     //We have our position - save it and break from this loop
       
  5421                     if ( index > 1 )
       
  5422                         {
       
  5423                         posToInsertItem = index;
       
  5424                         }
       
  5425                     else 
       
  5426                         {
       
  5427                         //There are two or less items on this menu that will be displayed
       
  5428                         //Hence, push ITI options to the end of the list:
       
  5429                         posToInsertItem = numOfMenuItems;
       
  5430                         }
       
  5431                     break;
       
  5432                     }
       
  5433                 }
       
  5434             }
       
  5435         else 
       
  5436             {
       
  5437             posToInsertItem = numOfMenuItems;
       
  5438             }
       
  5439         }
       
  5440     //Now we have the position at which we need to insert the menu item. 
       
  5441     if (
       
  5442 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  5443     iQwertyInputMode &&
       
  5444 #endif   		
       
  5445     IsLanguageSupportPrediction() && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  5446         {
       
  5447         AddPredictiveModeOptionsL(aMenuPane, posToInsertItem);
       
  5448         }
       
  5449     else
       
  5450         {
       
  5451         AddInputLanguageItemL(aMenuPane, posToInsertItem);
       
  5452         }
       
  5453     }
       
  5454 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5455 
       
  5456 
       
  5457 void CAknFepManager::AddEditSubmenuL(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5458     {
       
  5459     // Adds edit-submenu to options menu when required contidions are met.
       
  5460     // Edit-submenu is added if:
       
  5461     //  1. There is active editor on screen
       
  5462     //  2. Editor contains text or there is text in clipboard.
       
  5463     //  3. Editor is not in Find Pane.
       
  5464     //
       
  5465     // Since menu will have focus, we also need to remeber certain values
       
  5466     // to be able to access undelying editor attributes.
       
  5467     
       
  5468     CAknEdwinState* editorState = EditorState();
       
  5469     iEditorCcpuStatus = 0;        
       
  5470     if (editorState && editorState->CcpuState())
       
  5471         {
       
  5472         iEditorCcpuStatus = EditorCcpuStatus(editorState);    
       
  5473         }
       
  5474     else
       
  5475         {
       
  5476         // The editor doesn't have ccpu-capability, doen't display the menu.
       
  5477         return; 
       
  5478         }            
       
  5479     TInt index;
       
  5480     if (aMenuPane->MenuItemExists(EAknCmdEditTextMenu, index))
       
  5481         {
       
  5482         return;    
       
  5483         }
       
  5484         
       
  5485     iRememberLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();      
       
  5486     
       
  5487     if (iRememberLength > 0 || (iEditorCcpuStatus & ECcpuStatusFlagCanPaste))
       
  5488         {
       
  5489 		if (aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index) ||
       
  5490 				aMenuPane->MenuItemExists(EAknCmdInputLanguage, index) ||
       
  5491 		    aMenuPane->MenuItemExists(EAknCmdHelp, index) || 
       
  5492             aMenuPane->MenuItemExists(EAknCmdExit, index))  
       
  5493             {
       
  5494             TBuf<KMaxFileName> titleStr;
       
  5495             StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_SUBMENU_TITLE);          
       
  5496         
       
  5497             CAknFepUiInterfaceMenuPane::SItemData mData;
       
  5498                             
       
  5499             mData.iCommandId = EAknCmdEditTextMenu;
       
  5500             mData.iCascadeId = R_AKNFEP_EDIT_SUBMENU;  
       
  5501             mData.iFlags = 0;
       
  5502             mData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1).Left(
       
  5503                CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  5504                             
       
  5505             aMenuPane->InsertMenuItemL(mData, index);  
       
  5506 
       
  5507  			if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5508     			{
       
  5509     			    aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);
       
  5510     			   
       
  5511     			}
       
  5512             // Remember editor state, because there is no access to it while
       
  5513             // menu is on screen.
       
  5514             iRememberEditorState = editorState;              
       
  5515             }                                           
       
  5516         }               
       
  5517     }
       
  5518 
       
  5519     
       
  5520 void CAknFepManager::DisableEditSubmenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5521     {
       
  5522     aMenuPane->SetItemDimmed(EAknEditMenuCmdCopyText, ETrue); 
       
  5523     aMenuPane->SetItemDimmed(EEikCmdEditCopy, ETrue);
       
  5524     aMenuPane->SetItemDimmed(EAknEditMenuCmdCutText, ETrue);  
       
  5525     aMenuPane->SetItemDimmed(EEikCmdEditCut, ETrue);
       
  5526     aMenuPane->SetItemDimmed(EEikCmdEditPaste, ETrue);                                          
       
  5527     
       
  5528     if (iRememberLength > 0)
       
  5529         {           
       
  5530         if (iEditorCcpuStatus & ECcpuStatusFlagCanCopy)
       
  5531             {
       
  5532             aMenuPane->SetItemDimmed(EEikCmdEditCopy, EFalse);              
       
  5533             }
       
  5534         else
       
  5535             {
       
  5536             aMenuPane->SetItemDimmed(EAknEditMenuCmdCopyText, EFalse);                                      
       
  5537             }   
       
  5538                         
       
  5539         if (iEditorCcpuStatus & ECcpuStatusFlagCanCut)
       
  5540             {
       
  5541             aMenuPane->SetItemDimmed(EEikCmdEditCut, EFalse);               
       
  5542             }
       
  5543         else
       
  5544             {
       
  5545             aMenuPane->SetItemDimmed(EAknEditMenuCmdCutText, EFalse);                                   
       
  5546             }               
       
  5547         }
       
  5548                         
       
  5549     if (iEditorCcpuStatus & ECcpuStatusFlagCanPaste)            
       
  5550         {
       
  5551         aMenuPane->SetItemDimmed(EEikCmdEditPaste, EFalse);             
       
  5552         }   
       
  5553     }
       
  5554     
       
  5555 
       
  5556 void CAknFepManager::StartCcpuModeL(TBool aCopyMode)
       
  5557     {
       
  5558     ResetCcpuFlags();
       
  5559     if (!iUiInterface->SoftkeysExist())
       
  5560         {
       
  5561         iUiInterface->CreateSoftkeys(R_AVKON_SOFTKEYS_EMPTY, this);
       
  5562         }
       
  5563         
       
  5564     TBool update = EFalse;
       
  5565     if (aCopyMode)
       
  5566         {
       
  5567         SetCcpuFlag(ECcpuStateStartCopy);
       
  5568         update = UpdateCBALabelL(ELeftSoftkeyIndex, EAknFepSoftkeyStartCopy, 
       
  5569                                  R_AKNFEP_SOFTKEY_CCPU_START);      
       
  5570         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EAknFepSoftkeyStartCopy, 
       
  5571                                    R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
  5572         }
       
  5573     else
       
  5574         {
       
  5575         SetCcpuFlag(ECcpuStateStartCut);
       
  5576         update = UpdateCBALabelL(ELeftSoftkeyIndex, EAknFepSoftkeyStartCut, 
       
  5577                                  R_AKNFEP_SOFTKEY_CCPU_START);               
       
  5578         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EAknFepSoftkeyStartCut, 
       
  5579                                    R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
  5580         }
       
  5581         
       
  5582     update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow,
       
  5583                               R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  5584         
       
  5585     if (update)
       
  5586         {
       
  5587         iUiInterface->DrawSoftkeysNow();
       
  5588         }           
       
  5589 
       
  5590     iIndicator->SetCopyMode(ETrue);
       
  5591     UpdateIndicators(); // updates status of indicators
       
  5592     }
       
  5593 
       
  5594 
       
  5595 TBool CAknFepManager::OkToActivateSelectionMode() const
       
  5596     {
       
  5597     if (iFepManState != EAknFepStateNull && 
       
  5598         iInputCapabilities.FepAwareTextEditor() &&
       
  5599         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5600         {               
       
  5601         return ETrue;       
       
  5602         }
       
  5603     
       
  5604     return EFalse;  
       
  5605     }
       
  5606 
       
  5607 
       
  5608 TBool CAknFepManager::HandleCcpuModeKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode,
       
  5609                                              TKeyResponse& aRetCode, TBool aLongPressFlag)
       
  5610     {
       
  5611     TKeyPressLength length = aKeyEvent.iRepeats ? ELongKeyPress : EShortKeyPress;
       
  5612     TBool indicLang = TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(
       
  5613                                      iLanguageCapabilities.iInputLanguageCode))
       
  5614 #ifdef RD_HINDI_PHONETIC_INPUT
       
  5615     || TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(TLanguage(
       
  5616                                      iLanguageCapabilities.iInputLanguageCode))
       
  5617 #endif
       
  5618     ;
       
  5619     if(aKeyEvent.iCode == EKeyEscape)
       
  5620         return EFalse;
       
  5621     if (aEventCode == EEventKey && aKeyEvent.iCode == '*')
       
  5622         {
       
  5623         iStarScan = aKeyEvent.iScanCode;
       
  5624         }
       
  5625 
       
  5626     if ((aKeyEvent.iScanCode == EStdKeyDevice0)
       
  5627      || (aKeyEvent.iScanCode == EStdKeyDevice1))
       
  5628         {
       
  5629         if (HashKeySelectionInUse()
       
  5630          && IsCcpuFlagSet(ECcpuStateHashDown))
       
  5631             {
       
  5632             if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5633                 {
       
  5634                 ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5635                 if (iModeBefore == ELatin
       
  5636                  || iModeBefore == EHiraganaKanji)
       
  5637                     {
       
  5638                     TBool preFlag = IsPredictive();
       
  5639                     TryChangePredictiveInputModeL(!preFlag);
       
  5640                     }
       
  5641                 else
       
  5642                     {
       
  5643                     TryChangeToModeBeforeL();
       
  5644                     }
       
  5645                 }
       
  5646             }
       
  5647         // Always let sofkeys fall through.
       
  5648         return EFalse;      
       
  5649         }
       
  5650                 
       
  5651     if (IsCcpuFlagSet(ECcpuStateSelectionEventPosted))
       
  5652         {
       
  5653         ClearCcpuFlag(ECcpuStateSelectionEventPosted);
       
  5654         return EFalse;  
       
  5655         }       
       
  5656                         
       
  5657     if (HashKeySelectionInUse())
       
  5658         {       
       
  5659         if (aKeyEvent.iScanCode == EStdKeyHash && aEventCode == EEventKeyDown
       
  5660             && iInputCapabilities.FepAwareTextEditor())
       
  5661             {
       
  5662             SetCcpuFlag(ECcpuStateHashDown);
       
  5663             iHashKeyMan->ResetPreviousSelectionStyleMode();
       
  5664             return EFalse;
       
  5665             }
       
  5666             
       
  5667         if (!IsOnlyNumericPermitted())
       
  5668             {
       
  5669             if (IsFeatureSupportedJapanese())
       
  5670                 {
       
  5671                 if (FepUI()->IsValidShiftKeyPress()
       
  5672                  && aKeyEvent.iScanCode == iStarScan
       
  5673                  && !iQwertyInputMode
       
  5674                  && !(iMode == EKatakana && iFepManState == EAknFepStateUIActive))
       
  5675                     {
       
  5676                     if ( aEventCode == EEventKeyUp && !aLongPressFlag
       
  5677                      && !(iMode == ELatin && WesternPredictive()
       
  5678                           && iFepManState == EAknFepStateUIActive))
       
  5679                         {
       
  5680                         if (!IsCcpuFlagSet(ECcpuStateIgnoreStarUp))
       
  5681                             {
       
  5682                             LaunchSpecialCharacterTableL();
       
  5683                             }
       
  5684                         return EFalse;
       
  5685                         }
       
  5686                     else if ( aEventCode == EEventKey
       
  5687                            && !aLongPressFlag
       
  5688                            && length == ELongKeyPress )
       
  5689                         {
       
  5690                         LaunchSelectModeMenuL();
       
  5691                         aRetCode = EKeyWasConsumed;
       
  5692                         return ETrue;
       
  5693                         }
       
  5694                     }
       
  5695                 }
       
  5696             else
       
  5697                 {
       
  5698                 if ((aKeyEvent.iScanCode == iStarScan && aEventCode == EEventKeyUp &&
       
  5699                     !aLongPressFlag && !iQwertyInputMode) &&
       
  5700                 (!indicLang || WesternPredictive() || (iMode == ENumber || iMode == ENativeNumber) ))
       
  5701                 {
       
  5702                 // Disables *-key on korean multitapping mode
       
  5703                 if(IsKoreanInputLanguage() && iMode == EHangul)
       
  5704                 	{
       
  5705                 	SetCcpuFlag(ECcpuStateIgnoreStarUp);	
       
  5706                 	}
       
  5707 				
       
  5708                 if (!IsCcpuFlagSet(ECcpuStateIgnoreStarUp))
       
  5709                     {
       
  5710 #ifdef RD_SCALABLE_UI_V2                    
       
  5711                     if (iFepPluginManager->CurrentFepInputUI())
       
  5712                         {
       
  5713                         if (iFepPluginManager->CurrentFepInputUI()->HandleKeyL(EStdKeyNull, EShortKeyPress))
       
  5714                             {
       
  5715                             return EFalse;
       
  5716                             }
       
  5717                         }
       
  5718 #endif                        
       
  5719                     LaunchSelectModeMenuL();
       
  5720                     aRetCode = EKeyWasConsumed;
       
  5721                     return ETrue;
       
  5722                     }
       
  5723                 return EFalse;
       
  5724                 }
       
  5725             else if((aKeyEvent.iScanCode == iStarScan && aEventCode == EEventKey
       
  5726                 && !aLongPressFlag && !iQwertyInputMode)
       
  5727                 && (indicLang)
       
  5728                 && (! WesternPredictive())
       
  5729                 && (length == ELongKeyPress)
       
  5730                 && (iMode != ENumber && iMode != ENativeNumber ))            
       
  5731                 {
       
  5732                     LaunchSelectModeMenuL();
       
  5733                     return EFalse;
       
  5734                     }
       
  5735                 }
       
  5736             }
       
  5737         }
       
  5738         
       
  5739     if (IsCcpuFlagSet(ECcpuStateHashDown))
       
  5740         {
       
  5741         if (aEventCode == EEventKey)
       
  5742             {                   
       
  5743             if (aKeyEvent.iScanCode == EStdKeyDownArrow
       
  5744                 || aKeyEvent.iScanCode == EStdKeyRightArrow
       
  5745                 || aKeyEvent.iScanCode == EStdKeyLeftArrow
       
  5746                 || aKeyEvent.iScanCode == EStdKeyUpArrow)
       
  5747                 {
       
  5748 				if (IsFlagSet(EFlagInsideInlineEditingTransaction) && iMode == EHangul) 
       
  5749 					{
       
  5750 					CommitInlineEditL();
       
  5751        				iPtiEngine->ClearCurrentWord();
       
  5752 					}
       
  5753 										
       
  5754                 if ((IsCcpuFlagSet(ECcpuStateStartCopy)) ||
       
  5755                     (IsCcpuFlagSet(ECcpuStateStartCut)))
       
  5756                     {
       
  5757                     aRetCode = EKeyWasConsumed;             
       
  5758                     return ETrue;   
       
  5759                     }
       
  5760                 
       
  5761                 if (!IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  5762                     {
       
  5763                     // User wants to select and not to change mode, so cancel the mode change
       
  5764                     // caused by initial hash key press.                                    
       
  5765                     if(!(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5766                         {                               
       
  5767                         iHashKeyMan->SetPreviousSelectionStyleModeL();                                                   
       
  5768                         SetCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  5769                         TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  5770                         // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  5771                         // to avoid fep SimulateKeyEventL adding shift modifiers
       
  5772                         CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); 
       
  5773                         }
       
  5774                     }
       
  5775 
       
  5776                 // If prediction is changed while pressing hash-key,
       
  5777                 // it go back previous prediction state.
       
  5778                 if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5779                     {
       
  5780                     ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5781                     if (iModeBefore == ELatin
       
  5782                      || iModeBefore == EHiraganaKanji)
       
  5783                         {
       
  5784                         TBool preFlag = IsPredictive();
       
  5785                         TryChangePredictiveInputModeL(!preFlag);
       
  5786                         }
       
  5787                     else
       
  5788                         {
       
  5789                         TryChangeToModeBeforeL();
       
  5790                         }
       
  5791                     }
       
  5792                     
       
  5793                 if (WesternPredictive() && IsFlagSet(EFlagInsideInlineEditingTransaction))                    
       
  5794                     {      
       
  5795                     // This will commit inline edit if it is active for predictive mode.                              
       
  5796                     return EFalse;
       
  5797                     }
       
  5798 
       
  5799                 aRetCode = EKeyWasNotConsumed;
       
  5800                 return ETrue;
       
  5801                 }
       
  5802             else if (aKeyEvent.iScanCode == EStdKeyBackspace)   
       
  5803                 {                               
       
  5804                 if (!(aKeyEvent.iModifiers & EStdKeyLeftShift))
       
  5805                     {                                   
       
  5806                     // Simulate edit key + clear key functionality via hash key in no-edit-key device.              
       
  5807                     TKeyEvent ccpuStart = {127, EStdKeyBackspace, EStdKeyLeftShift, 0};
       
  5808                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);                    
       
  5809                     
       
  5810                     aRetCode = EKeyWasConsumed;             
       
  5811                     return ETrue;                                       
       
  5812                     }
       
  5813                 else if (!IsCcpuFlagSet(ECcpuStateHashKeyDeleteDone))
       
  5814                     {
       
  5815                     // Hash key + clear key was pressed, but hash key was released before
       
  5816                     // changing to selection mode. Need to return to previous mode, because
       
  5817                     // user didn't want to change input mode.                       
       
  5818                     iHashKeyMan->SetPreviousSelectionStyleModeL();
       
  5819                     SetCcpuFlag(ECcpuStateHashKeyDeleteDone);
       
  5820                     }
       
  5821 
       
  5822                 // If prediction is changed while pressing hash-key,
       
  5823                 // it go back previous prediction state.
       
  5824                 if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5825                     {
       
  5826                     ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5827                     if (iModeBefore == ELatin
       
  5828                      || iModeBefore == EHiraganaKanji)
       
  5829                         {
       
  5830                         TBool preFlag = IsPredictive();
       
  5831                         TryChangePredictiveInputModeL(!preFlag);
       
  5832                         }
       
  5833                     else
       
  5834                         {
       
  5835                         TryChangeToModeBeforeL();
       
  5836                         }
       
  5837                     }
       
  5838 
       
  5839                 }
       
  5840             }
       
  5841         else if (aKeyEvent.iScanCode == EStdKeyHash && aEventCode == EEventKeyUp)
       
  5842             {
       
  5843             ClearCcpuFlag(ECcpuStateHashDown
       
  5844                           | ECcpuStateHashKeyDeleteDone
       
  5845                           | ECcpuStateChangeToPredictionMode);
       
  5846             if (IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  5847                 {
       
  5848                 SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  5849                 ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  5850                 SetFlag(EFlagLongShiftKeyPress);
       
  5851 
       
  5852                 TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  5853                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);
       
  5854                 }
       
  5855 
       
  5856             return EFalse;
       
  5857             }
       
  5858         } 
       
  5859     
       
  5860     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateStartCut))    
       
  5861         {
       
  5862         if (aKeyEvent.iScanCode == EStdKeyDevice3 && aEventCode == EEventKey)
       
  5863             {
       
  5864             aRetCode = EKeyWasConsumed;                         
       
  5865             if (IsCcpuFlagSet(ECcpuStateStartCopy))
       
  5866                 {
       
  5867                 ProcessCommandL(EAknFepSoftkeyStartCopy);
       
  5868                 }
       
  5869             else
       
  5870                 {
       
  5871                 ProcessCommandL(EAknFepSoftkeyStartCut);                
       
  5872                 }                   
       
  5873             return ETrue;               
       
  5874             }       
       
  5875         else if (aKeyEvent.iScanCode < EStdKeyLeftArrow ||
       
  5876                  aKeyEvent.iScanCode > EStdKeyDownArrow) 
       
  5877             {       
       
  5878             aRetCode = EKeyWasConsumed;             
       
  5879             return ETrue;   
       
  5880             }
       
  5881         }       
       
  5882     else if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
  5883         {       
       
  5884         if ((aKeyEvent.iScanCode >= EStdKeyLeftArrow) && (aKeyEvent.iScanCode <= EStdKeyDownArrow)) 
       
  5885             {   
       
  5886             if (!(aKeyEvent.iModifiers & EModifierShift))
       
  5887                 {
       
  5888                 TKeyEvent ccpuStart = aKeyEvent;
       
  5889                 ccpuStart.iModifiers |= EModifierShift;
       
  5890                 ccpuStart.iModifiers |= EModifierRightShift;
       
  5891                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);        
       
  5892                 
       
  5893                 aRetCode = EKeyWasConsumed;
       
  5894                 return ETrue;                                                                                                       
       
  5895                 }  
       
  5896             else
       
  5897                 {
       
  5898                 aRetCode = EKeyWasNotConsumed;              
       
  5899                 return ETrue;
       
  5900                 }               
       
  5901             }
       
  5902         
       
  5903         TCursorSelection cursorSelection;
       
  5904         if( iInputCapabilities.FepAwareTextEditor() )
       
  5905         	{
       
  5906 			iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  5907 			if( (aEventCode ==  EEventKeyUp) && (cursorSelection.Length() == 0) 
       
  5908 				&& ((aKeyEvent.iScanCode ==  EStdKeyBackspace) || (aKeyEvent.iCode ==  EKeyBackspace)
       
  5909 				|| (aKeyEvent.iScanCode ==  EStdKeyDelete) || (aKeyEvent.iCode ==  EKeyDelete))) 
       
  5910 				{
       
  5911 				ClearCcpuFlag(ECcpuStateButton);
       
  5912 				}
       
  5913 			}
       
  5914         if (aKeyEvent.iScanCode != EStdKeyBackspace && aKeyEvent.iCode != EKeyOK)   
       
  5915             {                           
       
  5916             aRetCode = EKeyWasConsumed;
       
  5917             return ETrue;                                                       
       
  5918             }
       
  5919         else
       
  5920             {
       
  5921             if (iInputCapabilities.FepAwareTextEditor())            
       
  5922                 {
       
  5923                 TCursorSelection cursorSelection;                               
       
  5924                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  5925                 if (cursorSelection.Length() == 0)      
       
  5926                     {
       
  5927                     aRetCode = EKeyWasConsumed;
       
  5928                     return ETrue;                                                                           
       
  5929                     }
       
  5930                 else if (aKeyEvent.iScanCode == EStdKeyBackspace)
       
  5931                     {
       
  5932                     // Selection will be removed, handle cba button state accordingly                    
       
  5933                     if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() ==
       
  5934                         cursorSelection.Length())
       
  5935                         {
       
  5936                         // Whole text was selected and will be removed. Cancel the ccpu mode.
       
  5937                         ProcessCommandL(EAknFepSoftkeyCloseWindow);
       
  5938                         }
       
  5939                     else    
       
  5940                         {
       
  5941                         // Part of the text will be removed. Set Cba-buttons to initial ccpu-mode status.                        
       
  5942                         __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
  5943                                     AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  5944                  
       
  5945                         TBool update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
  5946                         update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow, R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  5947                         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ); 
       
  5948                         if (update)
       
  5949                             {
       
  5950                             iUiInterface->DrawSoftkeysNow();
       
  5951                             }                                                                     
       
  5952                         }
       
  5953                     }                    
       
  5954                 }
       
  5955             }                                   
       
  5956         }
       
  5957         
       
  5958     return EFalse;  
       
  5959     }
       
  5960     
       
  5961     
       
  5962 
       
  5963 void CAknFepManager::AddInputLanguageItemL(CAknFepUiInterfaceMenuPane* aMenuPane, TInt aIndex)
       
  5964     {
       
  5965     CAknFepUiInterfaceMenuPane::SItemData mData;
       
  5966     
       
  5967     TBuf<KMaxFileName> langStr;
       
  5968     TInt Inputlangindex;
       
  5969     if(!aMenuPane->MenuItemExists(EAknCmdInputLanguage, Inputlangindex))
       
  5970 	    {    
       
  5971     StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_LANGUAGE);
       
  5972     
       
  5973     mData.iCommandId = EAknCmdInputLanguage;
       
  5974     mData.iCascadeId = 0;  
       
  5975     mData.iFlags = 0;
       
  5976     mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  5977     
       
  5978     aMenuPane->InsertMenuItemL(mData, aIndex); 
       
  5979 	    }
       
  5980     
       
  5981     // Chinese input mode switching from the option menu
       
  5982     if (IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode())
       
  5983         {
       
  5984         // Add Chinese language items
       
  5985         langStr.Zero();
       
  5986         
       
  5987         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_MODE_CHI);
       
  5988         
       
  5989         mData.iCommandId = EAknCmdInputMethod;
       
  5990         mData.iCascadeId = R_AVKON_INPUT_MODE_SUB_MENU;
       
  5991         mData.iFlags = 0;
       
  5992         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  5993         
       
  5994         aMenuPane->InsertMenuItemL(mData, ++aIndex);
       
  5995         
       
  5996         // Check if the current engine has CangJie feature or not, if not
       
  5997         // then CangJie mode becomes invisible, similar impl in IsInputModeAvailable
       
  5998         // and DoChineseSubMenu        
       
  5999         TBool isCangJieSupported = EFalse;
       
  6000         MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineNormalCangjieQwerty);
       
  6001         if ( ptiCoreInfo )
       
  6002             {
       
  6003             isCangJieSupported = ptiCoreInfo->CapsBits() & ESupportCangjieInput;
       
  6004             }
       
  6005         
       
  6006         // Add Hong Kong CangJie option, option available only in HK variant and qwerty mode
       
  6007         if ( iLanguageCapabilities.iInputLanguageCode == 
       
  6008              ELangHongKongChinese && isCangJieSupported )
       
  6009             {
       
  6010             langStr.Zero();
       
  6011             
       
  6012             StringLoader::Load(langStr, R_AKNFEP_OPTIONS_CANGJIE_MODE);
       
  6013             
       
  6014             mData.iCommandId = EChinFepCmdModeCangJieOption;
       
  6015             mData.iCascadeId = 0;
       
  6016             mData.iFlags = 0;
       
  6017             mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6018             
       
  6019             aMenuPane->InsertMenuItemL(mData, ++aIndex);          
       
  6020             }
       
  6021         }
       
  6022     }
       
  6023 
       
  6024 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6025 // Predictive QWERTY (XT9) changes ---->
       
  6026 void CAknFepManager::AddPredictiveModeOptionsL(CAknFepUiInterfaceMenuPane* aMenuPane, 
       
  6027                                                TInt aIndex ) const
       
  6028     {
       
  6029     CAknFepUiInterfaceMenuPane::SItemData mData;
       
  6030     
       
  6031     HBufC* inputMenuStr = StringLoader::LoadLC(R_AKNFEP_PRED_OPTIONS_INPUT_OPTIONS);
       
  6032     
       
  6033     mData.iCommandId = 0;
       
  6034     mData.iCascadeId = R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU;  
       
  6035     mData.iFlags = 0;
       
  6036     mData.iText.Copy(inputMenuStr->Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6037     
       
  6038     CleanupStack::PopAndDestroy(inputMenuStr);
       
  6039     
       
  6040     aMenuPane->InsertMenuItemL(mData, aIndex);
       
  6041        
       
  6042     // Chinese input mode switching from the option menu
       
  6043     if (IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode())
       
  6044         {
       
  6045         // Add Chinese language items
       
  6046         TBuf<KMaxFileName> langStr;
       
  6047         
       
  6048         langStr.Zero();
       
  6049         
       
  6050         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_MODE_CHI);
       
  6051         
       
  6052         mData.iCommandId = EAknCmdInputMethod;
       
  6053         mData.iCascadeId = R_AVKON_INPUT_MODE_SUB_MENU;
       
  6054         mData.iFlags = 0;
       
  6055         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6056         
       
  6057         aMenuPane->InsertMenuItemL(mData, ++aIndex);
       
  6058         
       
  6059         // Check if the current engine has CangJie feature or not, if not
       
  6060         // then CangJie mode becomes invisible, similar impl in IsInputModeAvailable
       
  6061         // and DoChineseSubMenu        
       
  6062         TBool isCangJieSupported = EFalse;
       
  6063         MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineNormalCangjieQwerty);
       
  6064         if ( ptiCoreInfo != NULL)
       
  6065             {
       
  6066             isCangJieSupported = ptiCoreInfo->CapsBits() & ESupportCangjieInput;
       
  6067             }
       
  6068 #ifdef __HALF_QWERTY_KEYPAD
       
  6069         isCangJieSupported = isCangJieSupported && (iKeyboardType != EPtiKeyboardHalfQwerty);
       
  6070 #endif //__HALF_QWERTY_KEYPAD
       
  6071         
       
  6072         // Add Hong Kong CangJie option, option available only in HK variant and qwerty mode
       
  6073         if ( iLanguageCapabilities.iInputLanguageCode == ELangHongKongChinese && isCangJieSupported )
       
  6074             {
       
  6075             langStr.Zero();
       
  6076             
       
  6077             StringLoader::Load(langStr, R_AKNFEP_OPTIONS_CANGJIE_MODE);
       
  6078             
       
  6079             mData.iCommandId = EChinFepCmdModeCangJieOption;
       
  6080             mData.iCascadeId = 0;
       
  6081             mData.iFlags = 0;
       
  6082             mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6083             
       
  6084             aMenuPane->InsertMenuItemL(mData, ++aIndex);          
       
  6085             }
       
  6086         }
       
  6087     }
       
  6088 
       
  6089 void CAknFepManager::AddPredictiveModeEditMenuL(CAknFepUiInterfaceMenuPane* aMenuPane, 
       
  6090                                                 TInt aIndex ) const
       
  6091 	{
       
  6092 	// Remove Predictive Edit menu option if XT9 options are there --->
       
  6093 	aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, ETrue);
       
  6094     aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, ETrue);
       
  6095 	// Remove Predictive Edit menu option if XT9 options are there <---
       
  6096 	//if current writing language supports prediction then display input options settings --> 
       
  6097     //if current writing language does not supports prediction then display only input language 
       
  6098     //option to modify the writing language, when user wants to modify when edit query is launched. <--
       
  6099      TBool isLanguagugeSupportsPrediction = EFalse;
       
  6100      switch(iKeyboardType)
       
  6101      {
       
  6102 		 case EPtiKeyboardHalfQwerty:
       
  6103 #ifdef __HALF_QWERTY_KEYPAD		 
       
  6104 		 		isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive); 
       
  6105 #endif   //__HALF_QWERTY_KEYPAD
       
  6106 		    break;
       
  6107      case EPtiKeyboardQwerty4x12:
       
  6108      case EPtiKeyboardQwerty4x10:  
       
  6109      case EPtiKeyboardQwerty3x11:
       
  6110      case EPtiKeyboardCustomQwerty:
       
  6111 		 		isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternQwertyPredictive);
       
  6112 		    break;
       
  6113      case EPtiKeyboardNone:
       
  6114      case EPtiKeyboard12Key:
       
  6115 		 		isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
  6116 		    break;
       
  6117 		 default:
       
  6118 		 		isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
  6119 		    break;    
       
  6120 		 }
       
  6121      if (isLanguagugeSupportsPrediction && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6122          {
       
  6123          aMenuPane->SetItemDimmed(EAknCmdInputLanguage, ETrue);           
       
  6124          AddPredictiveModeOptionsL(aMenuPane, aIndex);
       
  6125          }
       
  6126 	}
       
  6127 // Predictive QWERTY (XT9) changes <----
       
  6128 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6129 void CAknFepManager::DoChineseSubMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6130     {
       
  6131     // ZhuyinFind & StrokeFind ONLY available for FindEditors
       
  6132     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6133         {
       
  6134         if (iMode == EZhuyinFind)
       
  6135             {
       
  6136             aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6137             }
       
  6138         
       
  6139         if (iMode == EStrokeFind)
       
  6140             {
       
  6141             aMenuPane->SetItemDimmed(EChinFepCmdModeStrokeFind, ETrue);
       
  6142             }        
       
  6143         }
       
  6144     else
       
  6145         {
       
  6146         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6147         aMenuPane->SetItemDimmed(EChinFepCmdModeStrokeFind, ETrue);
       
  6148         }
       
  6149     
       
  6150     // Customize menu item for Chinese mainland
       
  6151     if (iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
  6152         {
       
  6153         aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6154         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6155         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6156         
       
  6157         if (iMode == EPinyin)
       
  6158             {
       
  6159             aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6160             }
       
  6161         else if (iMode == EStroke)
       
  6162             {
       
  6163             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);
       
  6164             }
       
  6165         else if (iMode == ELatin)
       
  6166             {
       
  6167             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6168             }
       
  6169         else
       
  6170             return;
       
  6171         }
       
  6172     // Customize menu item for HongKong
       
  6173     else if (iLanguageCapabilities.iInputLanguageCode == ELangHongKongChinese)
       
  6174         {
       
  6175         aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6176         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6177         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);     
       
  6178         
       
  6179         TBool isCangJieSupported = EFalse;
       
  6180 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6181         if ( EPtiKeyboardQwerty3x11 == KeyboardLayout() )
       
  6182         	{
       
  6183         	isCangJieSupported = ETrue;
       
  6184         	}
       
  6185 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6186 #ifdef RD_INTELLIGENT_TEXT_INPUT      
       
  6187 #ifdef __HALF_QWERTY_KEYPAD
       
  6188         isCangJieSupported = isCangJieSupported && (iKeyboardType != EPtiKeyboardHalfQwerty);
       
  6189 #endif //__HALF_QWERTY_KEYPAD
       
  6190 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6191         
       
  6192         // CangJie is only for qwerty mode
       
  6193         if ( !iSharedDataInterface->QwertyInputMode() || !isCangJieSupported )
       
  6194             aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6195         
       
  6196         if (iMode == EStroke)
       
  6197             {
       
  6198             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);              
       
  6199             }
       
  6200         else if (iMode == ECangJie)
       
  6201             {
       
  6202             aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6203             }
       
  6204         else if (iMode == ELatin)
       
  6205             {
       
  6206             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6207             }
       
  6208         else
       
  6209             return;                
       
  6210         }
       
  6211     // Customize menu item for TaiWan
       
  6212     else if (iLanguageCapabilities.iInputLanguageCode == ELangTaiwanChinese)
       
  6213         {
       
  6214         aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6215         aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6216         
       
  6217         if (iMode == EStroke)
       
  6218             {
       
  6219             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);
       
  6220             }
       
  6221         else if (iMode == EZhuyin)
       
  6222             {
       
  6223             aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6224             }
       
  6225         else if (iMode == ELatin)
       
  6226             {
       
  6227             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6228             }
       
  6229         else
       
  6230             return;                 
       
  6231         }
       
  6232     else
       
  6233         return;    
       
  6234     }
       
  6235 #ifdef RD_SCALABLE_UI_V2
       
  6236        
       
  6237 void CAknFepManager::DoWesternTouchMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6238     {
       
  6239     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
  6240     // if mode is already hangul or language is not korean dim korean mode menu item
       
  6241     TInt index;
       
  6242         
       
  6243     if( iMode == EHangul || inputLanguage != ELangKorean || !(IsModePermitted(EHangul)))
       
  6244         {
       
  6245         if ( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, index) )
       
  6246             {
       
  6247             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, ETrue);
       
  6248             }
       
  6249         }
       
  6250     else
       
  6251         {
       
  6252         if ( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, index ) )
       
  6253             {
       
  6254             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, EFalse);
       
  6255             }
       
  6256         }
       
  6257     // remove Chinese specific items from menu
       
  6258     aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, ETrue);    
       
  6259     
       
  6260     if (aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index))
       
  6261         {
       
  6262         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6263         }
       
  6264 
       
  6265     // T9 stuff
       
  6266     if (WesternPredictive())
       
  6267         {
       
  6268         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6269         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6270         	{
       
  6271         	// Disable Autoword Completion feature for Touch Input
       
  6272         	#ifndef RD_SCALABLE_UI_V2  
       
  6273         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6274         	#endif // RD_SCALABLE_UI_V2
       
  6275         	}
       
  6276         	
       
  6277         if (aMenuPane->MenuItemExists(EAknCmdT9PredictiveT9Off, index)) 
       
  6278             {
       
  6279             aMenuPane->SetItemDimmed(EAknCmdT9PredictiveT9Off, EFalse);
       
  6280             }          	
       
  6281         }
       
  6282     else
       
  6283         {
       
  6284         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6285             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6286             iMode == ELatin &&
       
  6287             !IsKoreanInputLanguage() &&
       
  6288             iLanguageCapabilities.iSupportsWesternPredictive)
       
  6289             {
       
  6290             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6291             }
       
  6292         }
       
  6293 
       
  6294     if (  ( iMode == ENumber || iMode == ENativeNumber ) &&
       
  6295         (iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode)) )
       
  6296         {
       
  6297         aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse); 
       
  6298         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6299         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6300         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6301         if( iMode == EHangul || inputLanguage == ELangKorean)
       
  6302             {
       
  6303             TInt index;
       
  6304             if ( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, index ) )
       
  6305                 {
       
  6306                 aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, EFalse);
       
  6307                 }
       
  6308             }
       
  6309         }
       
  6310 
       
  6311     if ( IsModePermitted(ENumber) )
       
  6312         {
       
  6313         if (( iMode != ENumber ||
       
  6314             iMode == ENumber && iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
  6315             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6316             (iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic)) 
       
  6317             || ( iMode != ENumber ||
       
  6318             iMode == ENumber && iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
  6319             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6320             (iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic))
       
  6321             ||( iMode != ENumber ||
       
  6322             iMode == ENumber && iLanguageCapabilities.iIndicDigitsAllowed &&
       
  6323             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6324             (iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari)) &&
       
  6325             (!(iPermittedInputModes==EAknEditorNumericInputMode))) // hide the menu if number editor
       
  6326             
       
  6327             {
       
  6328             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6329             }
       
  6330         }
       
  6331     //modified by zhangfeiyan, fix bug SKIN-7LABJ3
       
  6332     if ( IsModePermitted( ENativeNumber ) )
       
  6333         {
       
  6334        if ( iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
  6335             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6336             iMode != ENativeNumber )
       
  6337             {
       
  6338             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, EFalse);
       
  6339             }
       
  6340         else if ( iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
  6341             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6342             iMode != ENativeNumber )
       
  6343             {
       
  6344             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, EFalse);
       
  6345             }   
       
  6346         else if( iLanguageCapabilities.iIndicDigitsAllowed && 
       
  6347             !( iAknEditorFlags & EAknEditorFlagLatinInputModesOnly ) &&       
       
  6348 
       
  6349             iMode != ENativeNumber )
       
  6350             {
       
  6351             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, EFalse);   
       
  6352             }
       
  6353         }
       
  6354 
       
  6355     if (IsAbleToLaunchSCT())
       
  6356         {
       
  6357         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6358             {
       
  6359             aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6360             }
       
  6361         }
       
  6362 
       
  6363     if ( iMode != ENumber && iMode != ENativeNumber && 
       
  6364          iPtiEngine->NumberOfLanguages() > 1 &&
       
  6365         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6366         {
       
  6367         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6368         }
       
  6369         
       
  6370     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6371         {
       
  6372         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6373         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6374         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6375         }
       
  6376     else if ( (iMode == ELatin || iMode == ENumber || iMode == ENativeNumber ) &&
       
  6377         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6378         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6379         {
       
  6380         // Text case mode is not available in secret editors.
       
  6381         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6382         }
       
  6383         
       
  6384     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6385         {
       
  6386         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6387         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6388         }   
       
  6389         
       
  6390     if (iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  6391         {
       
  6392         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);   
       
  6393         }
       
  6394     else if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  6395         {
       
  6396         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);   
       
  6397         }
       
  6398         
       
  6399     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);    
       
  6400     
       
  6401     if (!(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) 
       
  6402     && iFepPluginManager->IsNonLatinLanguage(TLanguage(iSharedDataInterface->InputTextLanguage())))
       
  6403         {
       
  6404         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6405         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6406         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6407         }             
       
  6408     if( iMode == EHangul )
       
  6409         {
       
  6410         //aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, EFalse);
       
  6411         //aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse);
       
  6412         
       
  6413         aMenuPane->SetItemDimmed(EAknCmdEditModeEnglish, EFalse);
       
  6414         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6415         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6416         
       
  6417         }
       
  6418     else
       
  6419         {
       
  6420         aMenuPane->SetItemDimmed(EAknCmdEditModeEnglish, ETrue);
       
  6421         }
       
  6422     }    
       
  6423 
       
  6424 void CAknFepManager::DoChineseTouchMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6425     {
       
  6426     TInt index;
       
  6427     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6428         && aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)) 
       
  6429         {
       
  6430         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);    
       
  6431         }
       
  6432 
       
  6433     if (WesternPredictive())
       
  6434         {
       
  6435         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6436         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6437         	{
       
  6438         	// Disable Autoword Completion feature for Touch Input
       
  6439         	#ifndef RD_SCALABLE_UI_V2  
       
  6440         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6441         	#endif // RD_SCALABLE_UI_V2
       
  6442         	}
       
  6443         	
       
  6444         if (aMenuPane->MenuItemExists(EAknCmdT9PredictiveT9Off, index)) 
       
  6445             {
       
  6446             aMenuPane->SetItemDimmed(EAknCmdT9PredictiveT9Off, EFalse);
       
  6447             }             	
       
  6448         }
       
  6449     else
       
  6450         {
       
  6451         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6452             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6453             iMode == ELatin)
       
  6454             {
       
  6455             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6456             }
       
  6457         }
       
  6458     if (IsAbleToLaunchSCT() &&
       
  6459         aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6460         {
       
  6461         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6462         }
       
  6463     if( (iFepPluginManager && (iFepPluginManager->PluginInputMode() != EPluginInputModeItut ) ) 
       
  6464             && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index) )  
       
  6465         {
       
  6466         aMenuPane->SetItemDimmed(EChinFepCmdInstructions, ETrue);
       
  6467         }
       
  6468     else if ( !(iPermittedInputModes == EAknEditorNumericInputMode ||
       
  6469         iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) )
       
  6470         {
       
  6471         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6472             {
       
  6473             aMenuPane->SetItemDimmed(EChinFepCmdInstructions, EFalse);
       
  6474             }
       
  6475         }
       
  6476 
       
  6477     if ( iMode != ENumber && iPtiEngine->NumberOfLanguages() > 1  &&
       
  6478         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6479         {
       
  6480         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6481         }
       
  6482 
       
  6483     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6484         {
       
  6485         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6486         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6487         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6488         }
       
  6489     else if ( (iMode == ELatin || iMode == ENumber) &&
       
  6490         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6491         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6492         {
       
  6493         // Text case mode is not available in secret editors.
       
  6494         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6495         }
       
  6496     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6497         {
       
  6498         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6499         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6500         }
       
  6501 
       
  6502     if ( IsModePermitted(ENumber) && iMode != ENumber )
       
  6503         {
       
  6504         //aMenuPane->SetItemDimmed(EChinFepCmdModeNumber, EFalse);  // original statement
       
  6505         aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6506         // end modifying
       
  6507         }
       
  6508     }
       
  6509 TBool CAknFepManager::IsChineseInputMode( TInt aMode )
       
  6510     {
       
  6511     return aMode == EPRCFind || aMode == ECangJie || aMode == EZhuyinFind
       
  6512            || aMode == EStrokeFind || aMode == EPinyin || aMode == EZhuyin
       
  6513            || aMode == EStroke;    
       
  6514     }
       
  6515 
       
  6516 #endif //RD_SCALABLE_UI_V2
       
  6517 void CAknFepManager::DoWesternMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6518     {
       
  6519     // remove Chinese specific items from menu
       
  6520     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6521     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6522     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6523     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
  6524     
       
  6525     
       
  6526     TInt pos=-1;
       
  6527     
       
  6528     if( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, pos ) )
       
  6529         {
       
  6530         // if mode is already hangul or language is not korean dim korean mode menu item
       
  6531         if( iMode == EHangul || inputLanguage != ELangKorean || !(IsModePermitted(EHangul)))
       
  6532             {
       
  6533             
       
  6534             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, ETrue);
       
  6535             }
       
  6536         else
       
  6537             {
       
  6538             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, EFalse);
       
  6539             }
       
  6540         }
       
  6541     
       
  6542     TInt index;
       
  6543     
       
  6544     if (aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index))
       
  6545         {
       
  6546         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6547         }
       
  6548 
       
  6549     // T9 stuff
       
  6550     if (WesternPredictive())
       
  6551         {
       
  6552         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6553 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  6554         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6555         	{
       
  6556         	// Disable Autoword Completion feature for Touch Input
       
  6557         	#ifndef RD_SCALABLE_UI_V2  
       
  6558         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6559         	#endif // RD_SCALABLE_UI_V2
       
  6560         	}
       
  6561 #endif  //RD_INTELLIGENT_TEXT_INPUT 
       
  6562         }
       
  6563     else
       
  6564         {
       
  6565         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6566             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6567             iMode == ELatin &&
       
  6568 			!IsKoreanInputLanguage() &&
       
  6569 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6570             // Predictive QWERTY (XT9) changes ---->
       
  6571             ((
       
  6572 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6573             iLanguageCapabilities.iSupportsWesternPredictive && !IsKoreanInputLanguage()
       
  6574 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6575 			&& !iQwertyInputMode) ||
       
  6576 			(iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode)
       
  6577 			)
       
  6578             // Predictive QWERTY (XT9) changes <----
       
  6579 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6580            )
       
  6581             {
       
  6582             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6583             }
       
  6584         }
       
  6585 
       
  6586     if ( ( iMode == ENumber || iMode == ENativeNumber ) && 
       
  6587         (iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode)) )
       
  6588         {
       
  6589         aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse);
       
  6590         }
       
  6591 
       
  6592     if ( IsModePermitted(ENumber) )
       
  6593         {
       
  6594         if ( iMode != ENumber ) // hide the menu if number editor
       
  6595             {
       
  6596             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6597             }
       
  6598 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6599         // Predictive QWERTY (XT9) changes ---->
       
  6600         // There's no need for numeric mode when full qwerty keyboard is in use (like in MAXI)
       
  6601         if (iQwertyInputMode)
       
  6602             {
       
  6603             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, ETrue);
       
  6604             }
       
  6605         // Predictive QWERTY (XT9) changes <----
       
  6606 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6607         }
       
  6608         
       
  6609     if ( IsModePermitted(ENativeNumber) && iMode != ENativeNumber)
       
  6610         {
       
  6611         if ( iLanguageCapabilities.iArabicIndicDigitsAllowed ) // hide the menu if number editor)
       
  6612             {
       
  6613             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, EFalse);
       
  6614             }
       
  6615         else if ( iLanguageCapabilities.iEasternArabicIndicDigitsAllowed ) // hide the menu if number editor)
       
  6616             {
       
  6617             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, EFalse);
       
  6618             }    
       
  6619         else if( iLanguageCapabilities.iIndicDigitsAllowed ) // hide the menu if number editor)
       
  6620             {
       
  6621             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, EFalse);   
       
  6622             }
       
  6623         }
       
  6624 
       
  6625     if (IsAbleToLaunchSCT())
       
  6626         {
       
  6627         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6628             {
       
  6629             aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6630             }
       
  6631         }
       
  6632     TInt writtingLanguage = 0;
       
  6633     if ( iMode != ENumber && iMode != ENativeNumber && iPtiEngine->NumberOfLanguages() > 1 &&
       
  6634         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
  6635         && aMenuPane->MenuItemExists( EAknCmdInputLanguage, writtingLanguage ) )
       
  6636         {
       
  6637         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6638         }
       
  6639     }
       
  6640 
       
  6641 void CAknFepManager::DoChineseMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6642     {
       
  6643     TInt index;
       
  6644     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6645        && aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)) 
       
  6646         {
       
  6647         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);    
       
  6648         }
       
  6649 
       
  6650     if (WesternPredictive())
       
  6651         {
       
  6652         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6653 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  6654         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6655         	{
       
  6656         	// Disable Autoword Completion feature for Touch Input
       
  6657         	#ifndef RD_SCALABLE_UI_V2  
       
  6658         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6659         	#endif // RD_SCALABLE_UI_V2
       
  6660         	}
       
  6661 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6662         }
       
  6663     else
       
  6664         {
       
  6665         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6666             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6667             iMode == ELatin)
       
  6668             {
       
  6669             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6670             }
       
  6671         }
       
  6672     if (IsAbleToLaunchSCT() &&
       
  6673         aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6674         {
       
  6675         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6676         }
       
  6677     if( iQwertyInputMode && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index) )
       
  6678         {
       
  6679         aMenuPane->SetItemDimmed(EChinFepCmdInstructions, ETrue);
       
  6680         }
       
  6681     else if ( !(iPermittedInputModes == EAknEditorNumericInputMode ||
       
  6682         iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) )
       
  6683         {
       
  6684         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6685             && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index)) 
       
  6686             {
       
  6687             aMenuPane->SetItemDimmed(EChinFepCmdInstructions, EFalse);
       
  6688             }
       
  6689         }
       
  6690 
       
  6691     if ( (!IsOnlyNumericPermitted()) && iPtiEngine->NumberOfLanguages() > 1  &&
       
  6692         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6693         {
       
  6694         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6695         // the follow added for phrase creation
       
  6696         TInt iptlanguage;
       
  6697         if ( !iIsUserdbdlgActive 
       
  6698 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  6699         && EPtiKeyboardHalfQwerty != KeyboardLayout() 
       
  6700 #endif
       
  6701         && IsChineseInputLanguage() )
       
  6702             {
       
  6703             aMenuPane->MenuItemExists( EAknCmdInputLanguage, iptlanguage );
       
  6704             MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
  6705             TInt inputLanguage = (ptilang)? ptilang->LanguageCode() : 0;          
       
  6706             if (iQwertyInputMode && (inputLanguage == ELangPrcChinese ||
       
  6707             	inputLanguage == ELangHongKongChinese ||
       
  6708             	inputLanguage == ELangTaiwanChinese))
       
  6709             	{
       
  6710             	TRAP_IGNORE(AddUserDBDlgItemL( aMenuPane, iptlanguage ));
       
  6711             	}
       
  6712             }
       
  6713         }
       
  6714 
       
  6715     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6716         {
       
  6717         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6718         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6719         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6720         }
       
  6721     else if ( (iMode == ELatin || iMode == ENumber) &&
       
  6722         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6723         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6724         {
       
  6725         // Text case mode is not available in secret editors.
       
  6726         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6727         }
       
  6728     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6729         {
       
  6730         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6731         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6732         }
       
  6733 
       
  6734     if ( IsModePermitted(ENumber) && iMode != ENumber )
       
  6735         {
       
  6736         //aMenuPane->SetItemDimmed(EChinFepCmdModeNumber, EFalse);  // original statement
       
  6737         aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6738         // end modifying
       
  6739         }
       
  6740     }
       
  6741 
       
  6742 void CAknFepManager::DoJapaneseMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6743     {
       
  6744     // remove Chinese specific items from menu
       
  6745     TInt index;
       
  6746     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6747         {
       
  6748         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, ETrue);
       
  6749         }
       
  6750         
       
  6751     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6752     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6753     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6754 
       
  6755     if (IsAbleToLaunchSCT()
       
  6756      && !iSharedDataInterface->QwertyInputMode())
       
  6757         {
       
  6758         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbolJp, EFalse);
       
  6759         }
       
  6760 
       
  6761     if (IsAbleToLaunchPCT()
       
  6762      && !iSharedDataInterface->QwertyInputMode())
       
  6763         {
       
  6764         aMenuPane->SetItemDimmed(EAknCmdEditInsertPictograph, EFalse);
       
  6765         }
       
  6766 
       
  6767     if (!(iPermittedInputModes & EAknEditorHiraganaKanjiInputMode) &&
       
  6768         aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)
       
  6769         )
       
  6770         {
       
  6771         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6772         }
       
  6773 
       
  6774     if (iPermittedInputModes == (EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode))
       
  6775         {
       
  6776         if (iMode == ELatin)
       
  6777             {
       
  6778             aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  6779             }
       
  6780         else if (iMode == ENumber)
       
  6781             {
       
  6782             aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  6783             }
       
  6784         }
       
  6785     else
       
  6786         {
       
  6787         // If the fep is running on the Janapnse User Dictionary Application,
       
  6788         // "User Dictionary" in editting options menu is hidden.
       
  6789         if (CEikonEnv::Static()->EikAppUi()->Application())
       
  6790             {
       
  6791             if (CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidUserDictApp)
       
  6792                 {
       
  6793                 aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6794                 }
       
  6795             }
       
  6796 
       
  6797         if (iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6798             {
       
  6799             aMenuPane->SetItemDimmed(EJapanFepCmdModeKutenCodeInput, EFalse);
       
  6800             }
       
  6801 
       
  6802         TInt value = iSharedDataInterface->ClearDirection();
       
  6803         if (value == EClearDirectionRight)
       
  6804             {
       
  6805             aMenuPane->SetItemDimmed(EAknCmdEditClearDirectionLeft, EFalse);
       
  6806             }
       
  6807         else
       
  6808             {
       
  6809             aMenuPane->SetItemDimmed(EAknCmdEditClearDirectionRight, EFalse);
       
  6810             }
       
  6811 
       
  6812         if (!iSharedDataInterface->QwertyInputMode())
       
  6813             {
       
  6814             if (IsPredictive(ELatin))
       
  6815                 {
       
  6816                 aMenuPane->SetItemDimmed(EJapanFepCmdPredictiveTextCascade, EFalse);
       
  6817                 }
       
  6818             else if ((iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
  6819                   && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6820                 {
       
  6821                 aMenuPane->SetItemDimmed(EJapanFepCmdMultitapPredictiveT9On, EFalse);
       
  6822                 }
       
  6823             }
       
  6824 
       
  6825         if (IsPredictive(EHiraganaKanji))
       
  6826             {
       
  6827             aMenuPane->SetItemDimmed(EJapanFepCmdModePredictiveOff, EFalse);
       
  6828             }
       
  6829         else if((iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6830              && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6831             {
       
  6832             aMenuPane->SetItemDimmed(EJapanFepCmdModePredictiveOn, EFalse);
       
  6833             }
       
  6834 
       
  6835         if (iMode != EHiraganaKanji && iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6836             {
       
  6837             aMenuPane->SetItemDimmed(EJapanFepCmdModeHiragana, EFalse);
       
  6838             }
       
  6839 
       
  6840         if (iCharWidth == EHalfWidthChar)
       
  6841             {
       
  6842             if (iPermittedInputModes & EAknEditorKatakanaInputMode && iMode != EKatakana)
       
  6843                 {
       
  6844                 aMenuPane->SetItemDimmed(EJapanFepCmdModeKatakana, EFalse);
       
  6845                 }
       
  6846 
       
  6847             if (iMode != ELatin && (iPermittedInputModes & EAknEditorHalfWidthTextInputMode
       
  6848                 || iPermittedInputModes & EAknEditorSecretAlphaInputMode))
       
  6849                 {
       
  6850                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  6851                 }
       
  6852 
       
  6853             if (iMode != ENumber
       
  6854              && iPermittedInputModes & EAknEditorNumericInputMode
       
  6855              && !iSharedDataInterface->QwertyInputMode())
       
  6856                 {
       
  6857                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  6858                 }
       
  6859 
       
  6860             if (iMode == EKatakana && iPermittedInputModes & EAknEditorFullWidthKatakanaInputMode)
       
  6861                 {
       
  6862                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6863                 }
       
  6864 
       
  6865             if (iMode == ELatin && !iWesternPredictive 
       
  6866              && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  6867                 {
       
  6868                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6869                 }
       
  6870 
       
  6871             if (iMode == ENumber
       
  6872              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode)
       
  6873                 {
       
  6874                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6875                 }
       
  6876             }
       
  6877         else // Full width Character
       
  6878             {
       
  6879             if (iMode != EKatakana && iPermittedInputModes & EAknEditorFullWidthKatakanaInputMode)
       
  6880                 {
       
  6881                 aMenuPane->SetItemDimmed(EJapanFepCmdModeKatakana, EFalse);
       
  6882                 }
       
  6883 
       
  6884             if (iMode != ELatin && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  6885                 {
       
  6886                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  6887                 }
       
  6888 
       
  6889             if (iMode != ENumber
       
  6890              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode
       
  6891              && !iSharedDataInterface->QwertyInputMode())
       
  6892                 {
       
  6893                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  6894                 }
       
  6895 
       
  6896             if (iMode == EKatakana && iPermittedInputModes & EAknEditorKatakanaInputMode)
       
  6897                 {
       
  6898                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  6899                 }
       
  6900 
       
  6901             if (iMode == ELatin && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  6902                 {
       
  6903                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  6904                 }
       
  6905 
       
  6906             if (iMode == ENumber
       
  6907              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode)
       
  6908                 {
       
  6909                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  6910                 }
       
  6911             }
       
  6912         }
       
  6913     }
       
  6914 
       
  6915 void CAknFepManager::HandlePointerEventInInlineTextL(TPointerEvent::TType /*aType*/, TUint /*aModifiers*/, TInt /*aPositionInInlineText*/)
       
  6916     {
       
  6917     }
       
  6918 
       
  6919 void CAknFepManager::GetFormatOfFepInlineText(TCharFormat& aFormat, 
       
  6920                                               TInt& aNumberOfCharactersWithSameFormat, 
       
  6921                                               TInt aPositionOfCharacter) const
       
  6922     {
       
  6923     if ( FepUI() )
       
  6924         {
       
  6925         FepUI()->GetFormatOfFepInlineText(aFormat, aNumberOfCharactersWithSameFormat, 
       
  6926                                           aPositionOfCharacter);
       
  6927         }
       
  6928     }
       
  6929 
       
  6930 void CAknFepManager::NumberModeChangeGSNotification()
       
  6931 	{
       
  6932 	iLanguageCapabilities.iNumericEditorDigitType = EDigitTypeUnknown;
       
  6933 	UpdateNumericEditorDigitType();	
       
  6934 	UpdateLocalDigitMode();
       
  6935 	}
       
  6936 
       
  6937 void CAknFepManager::HandleChangeInFocusL()
       
  6938     {
       
  6939     // Closing SCT has done focus change, so here just reset the flag.
       
  6940 #ifdef RD_SCALABLE_UI_V2	
       
  6941     if(iDisalbleFocusChangeForSCT)
       
  6942     {
       
  6943     iDisalbleFocusChangeForSCT = EFalse;
       
  6944     return;
       
  6945     }
       
  6946 #endif
       
  6947 
       
  6948     //The CCPU flag ECcpuStateShiftkeyWasPressedBeforeLosingFocus suggests that the candidate list was closed
       
  6949     //with a long key press of shift key. If so then, FEP needs to set the EFlagShiftKeyDepressed for the CCPU mode to work 
       
  6950     //correctly. The state of the shift state is copied to local variable isToSetShiftKeyStateDown because as a function of change
       
  6951     //of focus the FEP clears all the CCPU flags which would reset ECcpuStateShiftkeyWasPressedBeforeLosingFocus also.
       
  6952     TBool isToSetShiftKeyStateDown = IsCcpuFlagSet(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  6953     if (!Japanese() || iFepManState != EAknFepStateUIActive)
       
  6954         {
       
  6955         if (IsCcpuFlagSet(ECcpuStateIgnoreNextFocusChange))
       
  6956             {
       
  6957             // The focus event was caused by menu selection, don't clear all ccpu flags.
       
  6958             ClearCcpuFlag(ECcpuStateIgnoreNextFocusChange);
       
  6959             }
       
  6960         else
       
  6961             {
       
  6962             if((HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown) 
       
  6963              && IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode)))
       
  6964                 {
       
  6965                 ClearCcpuFlag(ECcpuStateHashDown);              
       
  6966                 SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  6967                 ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  6968                 SetFlag(EFlagLongShiftKeyPress);                
       
  6969                 TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  6970                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKeyUp);                                       
       
  6971                 }   
       
  6972             else
       
  6973                 {
       
  6974                 TBool isToSupressCursorMove = IsCcpuFlagSet(ECcpuStateSupressCursorMoveToEnd);
       
  6975                 TBool isCommitPredictiveWord = IsCcpuFlagSet(ECcpuStataCommitPredictiveWord);
       
  6976                 CancelCcpuMode();               
       
  6977                 if(isToSupressCursorMove)
       
  6978                     SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  6979                 if(isCommitPredictiveWord)
       
  6980                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);                
       
  6981                 }    
       
  6982             
       
  6983             }
       
  6984         SetCcpuFlag(ECcpuSupressEditMenuFromShiftUp);        
       
  6985         iPreviousEditingState = EStateNone;
       
  6986         iEditIndicatorAtLastUpdate = NULL;
       
  6987         ClearFlag( EFlagBidiCursorIsInitialized );
       
  6988 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  6989 // removing the no match indicator is not necessary for ITI 
       
  6990         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  6991             {
       
  6992             TryRemoveNoMatchesIndicatorL();
       
  6993             }
       
  6994 #endif             
       
  6995         UpdateCbaL(NULL);
       
  6996                     
       
  6997         if (iFepFullyConstructed)
       
  6998             {
       
  6999             SetCcpuFlag(ECcpuStateLosingFocus); // CommitInlineEditL needs to now we're losing focus (for cursor handling):           
       
  7000             CancelAllTimerActivity();
       
  7001             FepUI()->ExpireMultitapTimer();
       
  7002             ClearCcpuFlag(ECcpuStateLosingFocus); // Cleared right away to make sure nothing else is affected.              
       
  7003             }
       
  7004         // Forget shift key and chr key press if application or UI component is
       
  7005         // changed during shiftkey press.
       
  7006         ClearFlag(EFlagQwertyChrKeyDepressed);
       
  7007         //If candidate list was closed by long keypress of shift key, set the flag EFlagShiftKeyDepressed for CCPU mode
       
  7008         //to work correctly once it re-focuses on the editor.
       
  7009         if(isToSetShiftKeyStateDown)
       
  7010             {
       
  7011             SetFlag(EFlagShiftKeyDepressed);
       
  7012             ClearCcpuFlag(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  7013             }
       
  7014         else
       
  7015             {
       
  7016             ClearFlag(EFlagShiftKeyDepressed);
       
  7017             }
       
  7018         if ( iFepFullyConstructed && IsFepAwareTextEditor() )
       
  7019             {
       
  7020             //save state of old item
       
  7021             TransferFepStateToEditorL();
       
  7022 
       
  7023             if ( WesternPredictive() )
       
  7024                 {                                            
       
  7025 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7026                 // To rip off suggested word completion when there is a change in focus
       
  7027                 if(IsAutoCompleteOn())
       
  7028                 	{
       
  7029                 	RemoveSuggestedCompletionL();
       
  7030 
       
  7031                 	}
       
  7032 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  7033                 SetCcpuFlag(ECcpuStateLosingFocus);    // CommitInlineEditL needs to now we're losing focus (for cursor handling):                
       
  7034                 CommitInlineEditL(); 
       
  7035                 ClearCcpuFlag(ECcpuStateLosingFocus);  // Cleared right away to make sure nothing else is affected.                              
       
  7036                 }
       
  7037             else
       
  7038                 {
       
  7039                 TryCloseUiL();
       
  7040                 }
       
  7041                                  
       
  7042             iRememberLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  7043             if (iLastFocusedEditor && !IsExtendedFlagSet(EExtendedFlagFepAwareDialogLaunched))
       
  7044                 {
       
  7045                 iLastFocusedEditor->SetObserver(NULL);
       
  7046                 iLastFocusedEditor = NULL;
       
  7047                 }            
       
  7048 			// When editor launches a non-fep aware dialog, then we
       
  7049 			// should not set the observer to Null. Because if the dialog is 
       
  7050 			// destroyed we will not know and the dialog will remain orphaned.                                     
       
  7051 			// Also we need to know the fep editor pointer.
       
  7052             iLastFocusedEditor = EditorState();        
       
  7053             iEditorCcpuStatus = EditorCcpuStatus(iLastFocusedEditor); 
       
  7054             //iLastFocusedEditor->SetObserver(NULL);    
       
  7055 #ifdef RD_SCALABLE_UI_V2            
       
  7056             UnregisterObserver();
       
  7057 #endif // RD_SCALABLE_UI_V2 
       
  7058             }
       
  7059 
       
  7060         if (iPermittedInputModes & EAknEditorSecretAlphaInputMode &&
       
  7061             !(iPermittedInputModes & EAknEditorTextInputMode))
       
  7062             {
       
  7063             // For password editors.                
       
  7064             ClearFlag(EFlagSupressAutoUpdate);
       
  7065             } 
       
  7066 
       
  7067         // Losing focus is over, from this point on we are gaining focus.
       
  7068         ClearCcpuFlag(ECcpuStateLosingFocus);   
       
  7069 
       
  7070 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7071         if(iFnKeyManager)
       
  7072                 iFnKeyManager->ClearFnKeyState();
       
  7073                 
       
  7074         if(iResourceString)
       
  7075           {
       
  7076           delete iResourceString;
       
  7077           iResourceString = NULL;
       
  7078           }
       
  7079 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  7080         
       
  7081         // get input capabilities from newly focused item
       
  7082         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7083         iInputCapabilities = static_cast<const CCoeAppUi*>(coeEnv->AppUi())->InputCapabilities();
       
  7084         SetQwertyModeToInputcapbility();
       
  7085         if ( IsFepAwareTextEditor() )
       
  7086             {
       
  7087             // Now at the launch of non-fep aware dialogs we do not set the editor observer to NULL,
       
  7088             // and retain the editor pointer in iLastFocusedEditor. 
       
  7089             // So in case the editor is back in focus, we set iLastFocusedEditor to NULL
       
  7090             // and set the editor observer again.
       
  7091             
       
  7092 			// At launch of fep aware dialog on a fep aware editor say spell query launched on messaging editor,
       
  7093             // we have the flag EExtendedFlagFepAwareDialogLaunched set. 
       
  7094 			// So in this scenario we retain the observer for both the editor as we need to close the spell query
       
  7095             // on close of messaging editor. 
       
  7096             // Specific scenario is explained, the same is applicable for all general scenarios, for any
       
  7097             // fep aware dialog launched on any other fep aware editor.
       
  7098             if (iLastFocusedEditor && !IsExtendedFlagSet(EExtendedFlagFepAwareDialogLaunched))
       
  7099                 {
       
  7100                 iLastFocusedEditor->SetObserver(NULL);
       
  7101                 iLastFocusedEditor = NULL;
       
  7102                 }
       
  7103             if( EditorState() )
       
  7104                 {
       
  7105             	EditorState()->SetObserver(this);
       
  7106                 }
       
  7107             ConfigureFEPFromEditorStateL();
       
  7108 #ifdef RD_INTELLIGENT_TEXT_INPUT	
       
  7109 			if( PtiEngine() )
       
  7110 				{
       
  7111 	            if(!IsAutoCompleteOn())
       
  7112 	                {
       
  7113 					TInt tailLength = 0;
       
  7114 		            TRAP_IGNORE( PtiEngine()->HandleCommandL( 
       
  7115 									EPtiCommandGetAutoCompletionTailLength,
       
  7116 									&tailLength ));	
       
  7117 					if(tailLength)
       
  7118 						{					
       
  7119 						RemoveSuggestedAdvanceCompletionL();
       
  7120 						}
       
  7121 	                }	
       
  7122 				}
       
  7123 #endif
       
  7124             if (!iWesternPredictive && iMode == ELatin)
       
  7125                 {
       
  7126                 // It is possible to cause situation (by ill-acting client
       
  7127                 // app) where focus handling goes out of sync and there actually
       
  7128                 // is uncomitted inline edit operation going on in to-be-focused
       
  7129                 // editor. Multitapping mode doesn't like that, so we make sure here
       
  7130                 // that it won't happen.
       
  7131                 CancelInlineEdit();                         
       
  7132                 }             
       
  7133             AdjustCursorTypeForCurrentPosition();
       
  7134             
       
  7135             if (IsCcpuFlagSet(ECcpuStateUncommitWhenFocused))
       
  7136                 {
       
  7137                 // One of the ccpu editing options mode was started from
       
  7138                 // options menu. If there is active predictive word it
       
  7139                 // needs to be deactivated.
       
  7140                 ClearCcpuFlag(ECcpuStateUncommitWhenFocused);               
       
  7141                 DeactivatePredicitveWordAndMoveCursorL();                        
       
  7142                 }
       
  7143 #ifdef RD_SCALABLE_UI_V2                   
       
  7144             RegisterObserver();
       
  7145 #endif // RD_SCALABLE_UI_V2            		
       
  7146             }
       
  7147         else // no FepAwareTextEditor
       
  7148             {
       
  7149 #ifdef RD_SCALABLE_UI_V2
       
  7150             // register to receive TInputCapabilitiesEvent events
       
  7151             if ( SemiFepAwareTextEditor() )
       
  7152                 {
       
  7153                 RegisterObserver();
       
  7154                 TLanguage localLanguage = ELangTest;
       
  7155                 if (GetLocalLanguage( localLanguage ) )
       
  7156                     {
       
  7157                     iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
  7158                     if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
  7159                         {
       
  7160                         ChangeInputLanguageL(localLanguage);
       
  7161                         }
       
  7162                     }
       
  7163                 else if (iLanguageCapabilities.iLocalInputLanguageInUse)
       
  7164                     {
       
  7165                     iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
  7166                     ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  7167                     }
       
  7168 
       
  7169                 if (IsFlagSet(EFlagNewSharedDataInputLanguage) )
       
  7170                     {
       
  7171                     //Global mode or input language has been changed in general settings
       
  7172                     if ( !iLanguageCapabilities.iLocalInputLanguageInUse)
       
  7173                         {
       
  7174                         ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  7175                         }
       
  7176                     ClearFlag(EFlagNewSharedDataInputLanguage);
       
  7177                     }
       
  7178                 }
       
  7179 #endif // RD_SCALABLE_UI_V2
       
  7180             // Check for non Edwin derived editors (eg mfne, tel no editor etc)
       
  7181             if (iInputCapabilities.SupportsWesternNumericIntegerPositive() || 
       
  7182                 iInputCapabilities.SupportsWesternNumericIntegerNegative() || 
       
  7183                 iInputCapabilities.SupportsWesternNumericReal() )
       
  7184                 {
       
  7185                 SyncStates(EAknFepStateInitial);
       
  7186                 iPermittedInputModes = EAknEditorNumericInputMode;
       
  7187                 iAknEditorNumericKeymap = EAknEditorNativeKeysNumberModeKeymap;
       
  7188                 iAknEditorFlags = 0;
       
  7189                 iCharWidth = EHalfWidthChar;
       
  7190                 UpdateNumericEditorDigitType();
       
  7191                 
       
  7192                 if ( IsMfneEditor() ) 
       
  7193                     {
       
  7194                     UpdateLocalDigitMode();
       
  7195                     }
       
  7196                 
       
  7197                 if( IsInputModeAvailable(ENativeNumber) &&
       
  7198                     ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
  7199                       iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
  7200                       iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
  7201                     {
       
  7202                     TryChangeModeL( ENativeNumber );
       
  7203                     }
       
  7204                 else
       
  7205                     {
       
  7206                     TryChangeModeL( ENumber );
       
  7207                     }
       
  7208                 }
       
  7209             else //we don't have a valid editor
       
  7210                 {
       
  7211                 SyncStates(EAknFepStateNull);
       
  7212                 
       
  7213                 // Reset the qwerty shift case mode when we do not have a valis editor.
       
  7214                 ClearFlag(IsFlagSet( EFlagQwertyShiftMode ));
       
  7215                 if (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible) &&
       
  7216                     iIndicator)
       
  7217                     {
       
  7218                     iIndicator->SetState(EStateNone);
       
  7219                     iHybridAplphaChangedToAlphanumeric = EFalse; 
       
  7220                     }
       
  7221                 ClearFlag(EFlagForegroundUIComponentVisible);
       
  7222                 iPermittedInputModes = EAknEditorNullInputMode;
       
  7223                 
       
  7224 #ifdef RD_SCALABLE_UI_V2                
       
  7225                 RegisterObserver();               
       
  7226 #endif // RD_SCALABLE_UI_V2                      
       
  7227                 }            
       
  7228             }
       
  7229         }
       
  7230     else if (Japanese() && iFepManState == EAknFepStateUIActive)
       
  7231         {
       
  7232         if (iInputCapabilities.FepAwareTextEditor())
       
  7233             {
       
  7234             TryCloseUiL();
       
  7235             }
       
  7236         }
       
  7237     
       
  7238 #ifdef RD_SCALABLE_UI_V2
       
  7239         {
       
  7240         /*
       
  7241         if( iGainForeground )
       
  7242             {
       
  7243             iLoseForeAndGainFocus = EFalse;
       
  7244             }
       
  7245         else
       
  7246             {
       
  7247             iLoseForeAndGainFocus = ETrue;
       
  7248             }
       
  7249         SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  7250         */
       
  7251         CCoeControl* focusCtrl = static_cast<const CCoeAppUi*>(CCoeEnv::Static()->AppUi())->TopFocusedControl();         
       
  7252        CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
       
  7253        TBool bForeGround = aui->IsForeground();
       
  7254        if(iGainForeground && ! bForeGround)
       
  7255         {
       
  7256         iGainForeground = EFalse;
       
  7257         }
       
  7258         
       
  7259         if(iGainForeground && iNotifyPlugin)
       
  7260             {            
       
  7261             SendEventsToPluginManL( EPluginFocusChanged, 
       
  7262                                     iGainForeground && focusCtrl!=0 && focusCtrl->IsFocused());        
       
  7263             }
       
  7264         }
       
  7265 #endif // RD_SCALABLE_UI_V2
       
  7266         if( PtiEngine() && FepAwareTextEditor() )
       
  7267             {
       
  7268             if( FepAwareTextEditor()->DocumentLengthForFep() == 0 &&
       
  7269                 IsFlagSet(EFlagInsideInlineEditingTransaction)&&
       
  7270                 iFepManState == EAknFepStateUIActive )
       
  7271               {
       
  7272               PtiEngine()->ClearCurrentWord();                
       
  7273               TryCloseUiL();                
       
  7274               }
       
  7275             }
       
  7276 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7277     // Predictive QWERTY (XT9) changes ---->
       
  7278     ShowExactWordPopupIfNecessaryL();
       
  7279     // Predictive QWERTY (XT9) changes <----
       
  7280 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  7281     }
       
  7282 
       
  7283 void CAknFepManager::CleanUpFep()
       
  7284     {
       
  7285     if (iFepFullyConstructed)
       
  7286         {
       
  7287         CancelAllTimerActivity();
       
  7288         iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  7289         }
       
  7290     else
       
  7291         {
       
  7292         CommonDestroyFep();
       
  7293         }
       
  7294     }
       
  7295 
       
  7296 #ifdef RD_SCALABLE_UI_V2
       
  7297 void CAknFepManager::UnregisterObserver()
       
  7298     {
       
  7299 
       
  7300 		MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  7301     
       
  7302     	if ( mop )
       
  7303     		{
       
  7304     		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  7305     		mop->MopGetObject( extendedInputCapabilities );
       
  7306 
       
  7307     		if ( extendedInputCapabilities ) 
       
  7308     			{
       
  7309     			extendedInputCapabilities->UnregisterObserver( this );
       
  7310     			}
       
  7311     		}
       
  7312     }
       
  7313 
       
  7314 void CAknFepManager::RegisterObserver()
       
  7315     {
       
  7316 
       
  7317 	MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  7318 
       
  7319 	if ( mop )
       
  7320 		{
       
  7321 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  7322 		mop->MopGetObject( extendedInputCapabilities );
       
  7323 
       
  7324 		if ( extendedInputCapabilities ) 
       
  7325 			{
       
  7326 			extendedInputCapabilities->RegisterObserver( this );
       
  7327 			}
       
  7328 		}
       
  7329     }    
       
  7330  
       
  7331 #endif // RD_SCALABLE_UI_V2    
       
  7332     
       
  7333 void CAknFepManager::SimulateKeyEventL(TUint aKeyCode, TBool aActiveObj)
       
  7334     {
       
  7335     if (aActiveObj)
       
  7336         {
       
  7337         iSimulateKey = aKeyCode;
       
  7338         iAsyncOwnSimulateKey.CallBack();
       
  7339         }
       
  7340     else
       
  7341         {
       
  7342         CArrayFix<TUint>* simCharArray = new(ELeave) CArrayFixFlat<TUint>(1);
       
  7343         CleanupStack::PushL(simCharArray);
       
  7344         simCharArray->AppendL(aKeyCode);
       
  7345         SimulateKeyEventsL(simCharArray->Array());
       
  7346         CleanupStack::PopAndDestroy(); // simCharArray
       
  7347         }
       
  7348     }
       
  7349 
       
  7350 TInt CAknFepManager::ResetShiftKeyMonitorCallback(TAny* aObj)
       
  7351     {
       
  7352     TRAPD(err, static_cast<CAknFepManager*>(aObj)->ResetShiftKeyMonitorL());
       
  7353     if (err)
       
  7354         {
       
  7355         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
  7356         return KErrDied;
       
  7357         }
       
  7358     return KErrNone;
       
  7359     }
       
  7360 
       
  7361 void CAknFepManager::ResetShiftKeyMonitorL()
       
  7362     {
       
  7363     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); 
       
  7364     if(phoneIdle)
       
  7365     	{
       
  7366     	iShiftKeypressMonitor->Cancel();
       
  7367     	return;
       
  7368     	}
       
  7369     
       
  7370     SetFlag(EFlagLongShiftKeyPress);
       
  7371 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__    
       
  7372 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7373     // Copy-paste with shift+SKs is always available on ITU-T. On QWERTY,
       
  7374     // it's available if activated in the Central Repository.
       
  7375     if ( (!iQwertyInputMode || iSharedDataInterface->ShiftCopyPastingOnQwerty()) && 
       
  7376          !(iAknEditorFlags & EAknEditorFlagFindPane) )
       
  7377 #endif // RD_INTELLIGENT_TEXT_INPUT        
       
  7378 #else    
       
  7379     if (!iQwertyInputMode && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  7380 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
  7381         {
       
  7382         if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown)) 
       
  7383             {
       
  7384             SetCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  7385             iHashKeyMan->SetPreviousSelectionStyleModeL();
       
  7386             }
       
  7387     	if(iCandidatePopup)
       
  7388     		{	// if candidate list is launched and then a long key press of shift key is done, destroy the candidate list first
       
  7389 				iCandidatePopup->AttemptExitL(EFalse);
       
  7390 				HandleChangeInFocusL();
       
  7391     		}
       
  7392         if(!IsCcpuFlagSet(ECcpuStateCbaShown))
       
  7393 			{       
       
  7394 	        TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  7395     	    // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  7396         	// to avoid fep SimulateKeyEventL adding shift modifiers
       
  7397 	        CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey);
       
  7398 			SetCcpuFlag(ECcpuStateCbaShown);
       
  7399 			}
       
  7400         }
       
  7401 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  7402 #ifdef __HALF_QWERTY_KEYPAD   
       
  7403 	// we should not enter the copy-paste mode in find pane editors
       
  7404     if( EPtiKeyboardHalfQwerty == KeyboardLayout() && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  7405         {
       
  7406         CAknFepFnKeyManager::TFnKeyState fnState = FnKeyState();
       
  7407         
       
  7408         if( CAknFepFnKeyManager::EFnKeyNone != fnState 
       
  7409         		|| iFnCharInsertedForShift )
       
  7410             {
       
  7411             TText prevCh = PreviousChar();
       
  7412             if (prevCh == '#' || prevCh == '/')
       
  7413                 {
       
  7414                 RemovePreviousCharacterL();             
       
  7415                 }
       
  7416             // reset the fn state if it is FnNext
       
  7417             if( fnState == CAknFepFnKeyManager::EFnKeyNext )
       
  7418                 {
       
  7419                 SetFnKeyState( CAknFepFnKeyManager::EFnKeyNone );
       
  7420                 }
       
  7421             }
       
  7422         SetCcpuFlag( CAknFepManager::ECcpuStateEdwinInSelectionMode );
       
  7423         if(!IsCcpuFlagSet(ECcpuStateCbaShown))
       
  7424             {		
       
  7425 	        TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  7426          
       
  7427     	    // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  7428         	// to avoid fep SimulateKeyEventL adding shift modifiers
       
  7429         	CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey);    
       
  7430             SetCcpuFlag(ECcpuStateCbaShown); 			                                      
       
  7431 			}
       
  7432         }  
       
  7433 #endif //__HALF_QWERTY_KEYPAD
       
  7434 		          
       
  7435 #endif//RD_INTELLIGENT_TEXT_INPUT        
       
  7436     iShiftKeypressMonitor->Cancel();
       
  7437     }
       
  7438 
       
  7439 void CAknFepManager::CancelAllTimerActivity()
       
  7440     {
       
  7441     if (iShiftKeypressMonitor->IsActive())
       
  7442         {
       
  7443         iShiftKeypressMonitor->Cancel();
       
  7444         }
       
  7445     if (iConcatenationTimer->IsActive())
       
  7446         {
       
  7447         iConcatenationTimer->Cancel();
       
  7448         }
       
  7449     if (iChrKeypressMonitor->IsActive())
       
  7450         {
       
  7451         iChrKeypressMonitor->Cancel();
       
  7452         }
       
  7453     if (iPostEventCheck->IsActive())
       
  7454         {
       
  7455         iPostEventCheck->Cancel();
       
  7456         }
       
  7457     if ( iHashKeyMan )
       
  7458         {
       
  7459         iHashKeyMan->CancelHashKeyTimer();
       
  7460         }
       
  7461 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7462     if( iNumericResourceTimer )
       
  7463         {
       
  7464         TRAP_IGNORE( NumericResourceMultiTapTimerTimeoutL());
       
  7465         }
       
  7466 #endif
       
  7467     }
       
  7468 
       
  7469 TBool CAknFepManager::IsModePermitted(TInt aMode, TWidthChar aWidth) const
       
  7470     {
       
  7471     if (aWidth == ENoneWidthChar)
       
  7472         {
       
  7473         aWidth = iCharWidth;
       
  7474         }
       
  7475 
       
  7476     TBool isModePermitted = ETrue;
       
  7477     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;    
       
  7478     
       
  7479     if ( aMode == ENativeNumber && !IsInputModeAvailable( aMode ) )
       
  7480         {
       
  7481         if ( inputLanguage == ELangThai && iFepPluginManager && 
       
  7482                iFepPluginManager->PluginInputMode() != EPluginInputModeItut &&
       
  7483                !iQwertyInputMode)
       
  7484                {
       
  7485                return ETrue;
       
  7486                }        
       
  7487         return EFalse;
       
  7488         }
       
  7489     
       
  7490     TUint editorMode = EditorMode(aMode, aWidth);
       
  7491 
       
  7492     //Support Boxcn default Chinese inputmode when defaul inputmode is Cangjie Hongkong
       
  7493     //only if Chinese input is permitted in the editor
       
  7494     if (!( (iVariantPermittedModes | ELatinText | ELatinUpper | ELatinLower | EHiragana) & aMode) )
       
  7495         {
       
  7496         //the mode is never valid in this variant
       
  7497         isModePermitted = EFalse;
       
  7498         }
       
  7499     else if( aMode == ECangJie && !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  7500 		{
       
  7501 		if (iQwertyInputMode || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb
       
  7502 				|| iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ)
       
  7503 			{
       
  7504 			isModePermitted = ETrue;
       
  7505 			}
       
  7506 		else
       
  7507 			{
       
  7508 			isModePermitted = EFalse;
       
  7509 			}
       
  7510 		}
       
  7511     else if (!(iPermittedInputModes & editorMode))
       
  7512         {
       
  7513         isModePermitted = EFalse;
       
  7514         }
       
  7515     else if (((aMode == EPinyin) || (aMode == EZhuyin) || (aMode == EStroke) || (aMode == ECangJie)
       
  7516         ||   (aMode == EHiraganaKanji) || (aMode == EKatakana)
       
  7517         || (((aMode == ELatin) || (aMode == ENumber) || iMode == ENativeNumber ) && (iCharWidth == EFullWidthChar)))
       
  7518         && (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  7519         {
       
  7520         //the editor does not allow Chinese modes
       
  7521         isModePermitted = EFalse;
       
  7522         }
       
  7523     else if (((aMode == EStrokeFind) || (aMode == EZhuyinFind))
       
  7524         && (!(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)))
       
  7525         {
       
  7526         //StrokeFind and ZhuyinFind modes are only valid in a chinese find pane
       
  7527         isModePermitted = EFalse;
       
  7528         }
       
  7529     else
       
  7530         {
       
  7531         TUint editorsWhichAllowThisMode;
       
  7532         if (aMode == ENumber || aMode == ENativeNumber )
       
  7533             {
       
  7534             //The FEP's ENumber mode has a direct mapping to EAknEditorNumericInputMode
       
  7535             // or EAknEditorFullWidthNumericInputMode
       
  7536             editorsWhichAllowThisMode = EAknEditorNumericInputMode;
       
  7537             if (aWidth == EFullWidthChar)
       
  7538                 {
       
  7539                 editorsWhichAllowThisMode = EAknEditorFullWidthNumericInputMode;
       
  7540                 }
       
  7541             }
       
  7542         else if (aMode == EHiragana)
       
  7543             {
       
  7544             editorsWhichAllowThisMode = EAknEditorHiraganaInputMode;
       
  7545             }
       
  7546         else if (aMode == EKatakana || (aMode == ELatin && aWidth == EFullWidthChar))
       
  7547             {
       
  7548             editorsWhichAllowThisMode = EditorMode(aMode, aWidth);
       
  7549             }
       
  7550         else if (aMode == EHiraganaKanji)
       
  7551             {
       
  7552             // HiraganaKanji mode allows all input mode.
       
  7553             editorsWhichAllowThisMode = EAknEditorAllInputModes;
       
  7554             }
       
  7555         else if (aMode == EHangul)
       
  7556             {
       
  7557             editorsWhichAllowThisMode =(EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode | EAknEditorHalfWidthTextInputMode);     
       
  7558             }          
       
  7559         else
       
  7560             {
       
  7561             //if the editor allows Text Input or Secret Alpha Mode,
       
  7562             //we infer that Chinese Modes are valid
       
  7563             editorsWhichAllowThisMode =(EAknEditorTextInputMode | 
       
  7564                                         EAknEditorSecretAlphaInputMode | 
       
  7565                                         EAknEditorHalfWidthTextInputMode);
       
  7566             }
       
  7567         isModePermitted = iPermittedInputModes & editorsWhichAllowThisMode;
       
  7568         }
       
  7569 
       
  7570     return isModePermitted;
       
  7571     }
       
  7572 
       
  7573 TInt CAknFepManager::SyncStates(TAknFepManagerState aState)
       
  7574     {
       
  7575     TInt ret = KErrNone;
       
  7576     
       
  7577     if (!iFepFullyConstructed)
       
  7578         {
       
  7579         if (aState == EAknFepStateNull)
       
  7580             {
       
  7581             return KErrNone;
       
  7582             }
       
  7583                        
       
  7584         TRAP(ret, ConstructFullyL());
       
  7585         }
       
  7586     if (iFepFullyConstructed)
       
  7587         {
       
  7588         iFepManState = aState;
       
  7589         iKeyCatcher->SetState(aState);
       
  7590         }
       
  7591    
       
  7592     return ret;    
       
  7593     }
       
  7594 
       
  7595 TUint CAknFepManager::EditorMode(TInt aMode, TWidthChar aWidth) const
       
  7596     {
       
  7597     TInt editorMode = 0;
       
  7598     switch(aMode)
       
  7599         {
       
  7600         case EPinyin:
       
  7601         case EZhuyin:
       
  7602         case EStroke:
       
  7603         case ECangJie:
       
  7604         case EPRCFind:
       
  7605         case EZhuyinFind:
       
  7606         case EStrokeFind:
       
  7607         case EHangul:
       
  7608             {
       
  7609             editorMode = EAknEditorTextInputMode;
       
  7610             }
       
  7611             break;
       
  7612         case EHindi:
       
  7613         case ELatin:
       
  7614         case ELatinText:
       
  7615         case ELatinUpper:
       
  7616         case ELatinLower:
       
  7617             {
       
  7618             if (iPermittedInputModes & EAknEditorTextInputMode)
       
  7619                 {
       
  7620                  editorMode = EAknEditorTextInputMode;
       
  7621                 }
       
  7622             else if (iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
  7623                 {
       
  7624                 if (IsFeatureSupportedJapanese())
       
  7625                     {
       
  7626                     editorMode = EAknEditorHalfWidthTextInputMode;
       
  7627                     }
       
  7628                 else
       
  7629                     {
       
  7630                     editorMode = EAknEditorTextInputMode;
       
  7631                     }
       
  7632                 }
       
  7633             else
       
  7634                 {
       
  7635                 editorMode = EAknEditorSecretAlphaInputMode;
       
  7636                 }
       
  7637             if (aWidth == EFullWidthChar)
       
  7638                 {
       
  7639                 editorMode = EAknEditorFullWidthTextInputMode;
       
  7640                 }
       
  7641             }
       
  7642             break;
       
  7643         case EHiragana:
       
  7644             {
       
  7645             editorMode = EAknEditorHiraganaInputMode;
       
  7646             }
       
  7647             break;
       
  7648         case EHiraganaKanji:
       
  7649             {
       
  7650             editorMode = EAknEditorHiraganaKanjiInputMode;
       
  7651             }
       
  7652             break;
       
  7653         case EKatakana:
       
  7654             {
       
  7655             editorMode = EAknEditorKatakanaInputMode;
       
  7656             if (aWidth == EFullWidthChar)
       
  7657                 {
       
  7658                 editorMode = EAknEditorFullWidthKatakanaInputMode;
       
  7659                 }
       
  7660             }
       
  7661             break;
       
  7662         case ENumber:
       
  7663         case ENativeNumber:
       
  7664             {
       
  7665             editorMode = EAknEditorNumericInputMode;
       
  7666             if (aWidth == EFullWidthChar)
       
  7667                 {
       
  7668                 editorMode = EAknEditorFullWidthNumericInputMode;
       
  7669                 }
       
  7670             }
       
  7671             break;
       
  7672         default:
       
  7673             break;
       
  7674         }
       
  7675 
       
  7676     return editorMode;
       
  7677     }
       
  7678 
       
  7679 void CAknFepManager::LaunchPenSupportMenuL()
       
  7680     {
       
  7681     if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown))
       
  7682         {
       
  7683         return;
       
  7684         }
       
  7685 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7686 	if(iCandidatePopup)        
       
  7687 		{
       
  7688 		iCandidatePopup->AttemptExitL(EFalse);
       
  7689 		HandleChangeInFocusL();
       
  7690 		}
       
  7691 #endif		
       
  7692     
       
  7693     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  7694         {
       
  7695         TryRemoveNoMatchesIndicatorL();
       
  7696 		/*
       
  7697 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7698 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7699 	    When we launch Edit Menu.the word which in Inline Editing in the BackGorund 
       
  7700 	    Should not Commit*/        
       
  7701 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7702         CommitInlineEditL();
       
  7703 #endif
       
  7704 		/*
       
  7705 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7706 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7707 	    This Flag is useful for deciding whether "Matches" Menu Item can Visible 
       
  7708 	    or not*/
       
  7709 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7710         SetFlag(EFlagInlineEditInBackground);
       
  7711 #endif
       
  7712 		/*
       
  7713 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7714 	    "Matches" and "insert word" options are not available under Edit Menu.*/
       
  7715 #ifndef RD_INTELLIGENT_TEXT_INPUT        
       
  7716         ClearFlag(EFlagInsideInlineEditingTransaction);
       
  7717 #endif        
       
  7718         }
       
  7719     
       
  7720     CAknEdwinState* editorState = NULL;
       
  7721     if (iInputCapabilities.FepAwareTextEditor())
       
  7722         {
       
  7723         editorState = EditorState();
       
  7724         }
       
  7725     
       
  7726     iEditMenuBar = NULL;
       
  7727     if (editorState)
       
  7728         {
       
  7729         iEditMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  7730         }
       
  7731     
       
  7732     if (iEditMenuBar && 
       
  7733         !iEditMenuBar->IsDisplayed())
       
  7734         {
       
  7735         
       
  7736         iPenSupportMenu = ETrue;
       
  7737        // SetFlag(EFlagLaunchEditMenu);
       
  7738         CAknFepUiInterfaceMenuPane* menuPane = iEditMenuBar->MenuPane();
       
  7739         
       
  7740         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();        
       
  7741         if (!oldMenuPane)
       
  7742             {
       
  7743             menuPane = NULL;    
       
  7744             }
       
  7745         
       
  7746         iRememberEditorState = EditorState();
       
  7747   
       
  7748         iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuEdit);        
       
  7749         // It is unnecessary to add ROW SCT in Editting option menu.
       
  7750         iEditMenuBar->TryDisplayMenuBarL();
       
  7751         if (menuPane && menuPane->NumberOfItemsInPane() == 0)
       
  7752             {
       
  7753             // Edit menu do not contain any items.
       
  7754             iEditMenuBar->StopDisplayingMenuBar();
       
  7755             }
       
  7756         else
       
  7757             {
       
  7758             //adjust menu position to the front of dialog to
       
  7759             //avoid input capability is wrongly got
       
  7760             CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7761             CCoeAppUi* appUi = (CCoeAppUi*)(coeEnv->AppUi());
       
  7762             if( appUi->IsDisplayingDialog() )
       
  7763                 {
       
  7764                 iEditMenuBar->RemoveFromStack();
       
  7765                 iEditMenuBar->AddToStackL(ECoeStackPriorityDialog + 1, ECoeStackFlagStandard);                              
       
  7766                 }
       
  7767             }
       
  7768             
       
  7769         iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuOptions);
       
  7770         }
       
  7771         iPenSupportMenu = EFalse;
       
  7772     }
       
  7773 
       
  7774 void CAknFepManager::LaunchSelectModeMenuL()
       
  7775     {
       
  7776     if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown))
       
  7777         {
       
  7778         return;
       
  7779         }
       
  7780 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7781 	if(iCandidatePopup)        
       
  7782 		{
       
  7783 		iCandidatePopup->AttemptExitL(EFalse);
       
  7784 		HandleChangeInFocusL();
       
  7785 		}
       
  7786 #endif		
       
  7787     
       
  7788     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  7789         {
       
  7790         TryRemoveNoMatchesIndicatorL();
       
  7791 		/*
       
  7792 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7793 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7794 	    When we launch Edit Menu.the word which in Inline Editing in the BackGorund 
       
  7795 	    Should not Commit*/        
       
  7796 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7797         CommitInlineEditL();
       
  7798 #endif
       
  7799 		/*
       
  7800 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7801 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7802 	    This Flag is useful for deciding whether "Matches" Menu Item can Visible 
       
  7803 	    or not*/
       
  7804 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7805         SetFlag(EFlagInlineEditInBackground);
       
  7806 #endif
       
  7807 		/*
       
  7808 	    This code is the part of fixing TSW Error ID: BSAN-7G58DB :  Edit Menu : 
       
  7809 	    "Matches" and "insert word" options are not available under Edit Menu.*/
       
  7810 #ifndef RD_INTELLIGENT_TEXT_INPUT        
       
  7811         ClearFlag(EFlagInsideInlineEditingTransaction);
       
  7812 #endif        
       
  7813         }
       
  7814     
       
  7815     CAknEdwinState* editorState = NULL;
       
  7816     if (iInputCapabilities.FepAwareTextEditor())
       
  7817         {
       
  7818         editorState = EditorState();
       
  7819         }
       
  7820     
       
  7821     iEditMenuBar = NULL;
       
  7822     if (editorState)
       
  7823         {
       
  7824         iEditMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  7825         }
       
  7826     
       
  7827     if (iEditMenuBar && 
       
  7828         !iEditMenuBar->IsDisplayed())
       
  7829         {
       
  7830        // SetFlag(EFlagLaunchEditMenu);
       
  7831         CAknFepUiInterfaceMenuPane* menuPane = iEditMenuBar->MenuPane();
       
  7832         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();        
       
  7833         if (!oldMenuPane)
       
  7834             {
       
  7835             menuPane = NULL;    
       
  7836             }        
       
  7837          if(menuPane)
       
  7838         	SetFlag(EFlagLaunchEditMenu);
       
  7839         
       
  7840         iRememberEditorState = EditorState();
       
  7841         
       
  7842         // It is unnecessary to add ROW SCT in Editting option menu.
       
  7843         if (!IsFeatureSupportedJapanese())
       
  7844             {
       
  7845             iEditCharsPtr.Copy(KNullDesC);
       
  7846             iEditCharsPtr.Set( iSctEditChars->Des() );
       
  7847             
       
  7848             // get the SCT resource id from editor default settings
       
  7849             TInt currentEditorSCTResId = GetCurrentEditorSCTResId();
       
  7850             TInt charResourceId = ENoCharacters;
       
  7851             if ( currentEditorSCTResId == EDefaultNumericCharMapResId)
       
  7852                 {
       
  7853                 charResourceId = NumericModeSCTResourceId();
       
  7854                 if ( charResourceId != ENoCharacters && IsAbleToLaunchSCT()&& 
       
  7855                         EditorType() != CAknExtendedInputCapabilities::EEikSecretEditorBased)
       
  7856                     {
       
  7857                     
       
  7858                     if( menuPane != NULL )
       
  7859                         {
       
  7860                         menuPane->ConstructMenuSctRowL( iEditCharsPtr, charResourceId );
       
  7861                         }
       
  7862                     }
       
  7863                 else
       
  7864                     {
       
  7865                     currentEditorSCTResId = charResourceId;
       
  7866                     }   
       
  7867                 }
       
  7868             else
       
  7869                 {
       
  7870                 TInt sctChars = EAknSCTChiChineseInputModes;
       
  7871                 if (iCharWidth == EFullWidthChar)
       
  7872                     {
       
  7873                     sctChars = EAknSCTFullCase;
       
  7874                     }
       
  7875                 else
       
  7876                     {
       
  7877                     if (iMode == ELatin)
       
  7878                         {
       
  7879                         if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
  7880                             {
       
  7881                             sctChars = EAknSCTChiLatinInputModes;
       
  7882                             }
       
  7883                         else
       
  7884                             {
       
  7885                             if (iQwertyInputMode)
       
  7886                                 {
       
  7887                                 sctChars = EAknSCTQwerty;
       
  7888                                 }
       
  7889                             else
       
  7890                                 {
       
  7891                                 sctChars = EAknSCTUpperCase;
       
  7892                                 if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  7893                                     {
       
  7894                                     sctChars = EAknSCTLowerCase;
       
  7895                                     }
       
  7896                                 }
       
  7897                             }
       
  7898                         }
       
  7899                     else if (iMode == ENumber || iMode == ENativeNumber)
       
  7900                         {
       
  7901                         sctChars = EAknSCTNumeric;
       
  7902                         if ( ((iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) ||
       
  7903                             (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap)) &&
       
  7904                             !IsOnlyHalfWidthCharacterPermitted() )
       
  7905                             {
       
  7906                             sctChars = EAknSCTLowerCase;
       
  7907                             }
       
  7908                         }
       
  7909                     //delete for phrase creation
       
  7910 //                    else if (iMode == EStroke && iFepManState == EAknFepStateUIActive)
       
  7911 //                    	{
       
  7912 //                    	return;
       
  7913 //                    	}
       
  7914                     else if (iMode == EHiraganaKanji)
       
  7915                         {
       
  7916                         sctChars = EAknSCTFullCase;
       
  7917                         }
       
  7918                     else if(iMode == EKatakana)
       
  7919                         {
       
  7920                         sctChars = EAknSCTHalfCase;
       
  7921                         }
       
  7922                     }
       
  7923                     
       
  7924                 if (!(ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT))                    
       
  7925                     {
       
  7926                     if( menuPane && (EditorType() != CAknExtendedInputCapabilities::EEikSecretEditorBased))
       
  7927                         {
       
  7928                         if(IsAbleToLaunchSmiley())
       
  7929                             {
       
  7930                             sctChars |= EAknCharMapEmotionUse;
       
  7931                             }
       
  7932                         
       
  7933                         menuPane->ConstructMenuSctRowFromDialogL( sctChars, iEditCharsPtr, 
       
  7934                                                                   currentEditorSCTResId );                    
       
  7935                         }
       
  7936                     }
       
  7937                 }
       
  7938             }
       
  7939             iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuEdit);
       
  7940             iFepPluginManager->SetMenuState( ETrue ); 
       
  7941             iEditMenuBar->TryDisplayMenuBarL();
       
  7942             if (menuPane && menuPane->NumberOfItemsInPane() == 0)
       
  7943                 {
       
  7944                 // Edit menu do not contain any items.
       
  7945                 iEditMenuBar->StopDisplayingMenuBar();
       
  7946                 iFepPluginManager->ResetMenuState( ETrue );
       
  7947                 }
       
  7948             else
       
  7949                 {
       
  7950                 //adjust menu position to the front of dialog to
       
  7951                 //avoid input capability is wrongly got
       
  7952                 CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7953                 CCoeAppUi* appUi = (CCoeAppUi*)(coeEnv->AppUi());
       
  7954                 if( appUi->IsDisplayingDialog() )
       
  7955                     {
       
  7956                     iEditMenuBar->RemoveFromStack();
       
  7957                     // Set the MenuBar not focused, the later add to stack operation could unfocus other control correctly
       
  7958                     iEditMenuBar->SetFocus(EFalse);
       
  7959                     iEditMenuBar->AddToStackL(ECoeStackPriorityDialog + 1, ECoeStackFlagStandard);                              
       
  7960                     }
       
  7961                 }
       
  7962                 
       
  7963             iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuOptions);
       
  7964         }
       
  7965     }
       
  7966 
       
  7967 void CAknFepManager::LaunchMatchesPopupListL()
       
  7968     {
       
  7969     TInt noOfMatches = iPtiEngine->NumberOfCandidates();
       
  7970     if (noOfMatches > 1)    // 1 => only current match available, 0 => not in inline edit
       
  7971         {
       
  7972         // Create a list to pass to the dialog
       
  7973         CDesCArrayFlat* matchesList=new(ELeave)CDesCArrayFlat(1);
       
  7974         CleanupStack::PushL(matchesList);
       
  7975         iPtiEngine->GetCandidateListL(*matchesList);
       
  7976         TBuf<EMaximumFepWordLength> matchListDesc;
       
  7977         TInt matchListItemCount = matchesList->MdcaCount();
       
  7978         TInt currentIndex = ResolveCurrentCandidateListIndex(matchesList);      
       
  7979         for ( TInt ii=0; ii < matchListItemCount ; ii++)
       
  7980             {   
       
  7981             matchListDesc = matchesList->MdcaPoint(ii);
       
  7982             TChar tempChar = matchListDesc[0];
       
  7983             if(tempChar.IsDigit())
       
  7984                 {
       
  7985                 AknTextUtils::ConvertDigitsTo(matchListDesc,iLanguageCapabilities.iLocalDigitType);
       
  7986                 matchesList->Delete(ii);
       
  7987                 matchesList->InsertL(ii,matchListDesc);
       
  7988                 }
       
  7989             }
       
  7990 
       
  7991         // add 'Spell' to the bottom of the list
       
  7992         TResourceReader reader;
       
  7993         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7994         coeEnv->CreateResourceReaderLC(reader, R_AVKON_T9_MATCHES_QUERY_SPELL_ITEM);
       
  7995         matchesList->AppendL(reader.ReadTPtrC());
       
  7996         CleanupStack::PopAndDestroy(); // reader
       
  7997 
       
  7998         TInt index = 0;
       
  7999         SetFlag(EFlagForegroundUIComponentVisible);
       
  8000 
       
  8001         TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8002         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8003         // Fire up the dialog
       
  8004         TInt returnValue = iUiInterface->LaunchListPopupL(R_AVKON_T9_MATCHES_QUERY, index, 
       
  8005                                                           currentIndex, matchesList, NULL);
       
  8006         PrepareFepAfterDialogExitL(fepUid);
       
  8007         if(returnValue == EAknSoftkeyOk)
       
  8008             {// Selected item 'index' from the matches array
       
  8009             HandleChangeInFocusL();
       
  8010             TBuf<EMaximumFepWordLength> newText;
       
  8011             // Get current match from editor and show it as a default text in 'insert word' query.
       
  8012             iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
  8013                              iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
  8014             
       
  8015             if (index==noOfMatches) // => 'spell' item at the bottom of the list
       
  8016                 {
       
  8017                 LaunchInsertWordQueryL(newText, iUncommittedText);
       
  8018                 #ifdef RD_SCALABLE_UI_V2
       
  8019                 if( iFepFullyConstructed && iFepPluginManager )
       
  8020                     {
       
  8021                     iFepPluginManager->ResetMenuState();
       
  8022                     }
       
  8023                 #endif
       
  8024                 }
       
  8025             else
       
  8026                 { // insert word at index into text
       
  8027                 TBuf<EMaximumFepWordLength> modifiedMatch;                
       
  8028                 modifiedMatch.Copy(matchesList->MdcaPoint(index));
       
  8029                 TChar first(newText[0]);
       
  8030                 if (first.IsUpper())
       
  8031                     {
       
  8032                     TChar converted(modifiedMatch[0]);
       
  8033                     converted.UpperCase();
       
  8034                     modifiedMatch[0] = converted;
       
  8035                     }
       
  8036                 InsertTextFromDialogL(modifiedMatch, iUncommittedText);
       
  8037                 }
       
  8038             }
       
  8039         CleanupStack::PopAndDestroy(); // matchesList
       
  8040         }
       
  8041     }
       
  8042 
       
  8043 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  8044 // Predictive QWERTY (XT9) changes ---->
       
  8045 void CAknFepManager::LaunchCandidatePopupListL( TInt aFocusedIndex )
       
  8046     {
       
  8047     iKeyBackSpaceHit = 1;
       
  8048     //CPtiEngine* ptiEngine = iPtiEngine;
       
  8049     
       
  8050     // Addition for ITI features on FSQ.
       
  8051     // Before open candidate list, if FSQ is opened, 
       
  8052     // also need to check and close tooltip on it.
       
  8053     SendEventsToPluginManL( EPluginHideTooltip );
       
  8054     
       
  8055     // Before open candidate list, if touch ui is opened, 
       
  8056     // also need to close touch ui firstly.
       
  8057     if ( iFepPluginManager->PluginInputMode() != EPluginInputModeNone )
       
  8058         {
       
  8059         iFepPluginManager->ClosePluginInputUiL( ETrue );
       
  8060         }              
       
  8061 
       
  8062     iExactWordPopupContent->HidePopUp();
       
  8063         
       
  8064     TBool isShiftKeyDepressedAfterCandidateListLaunched = EFalse;
       
  8065     // Retrieve active index for QWERTY keypad when Best Prediction is Set
       
  8066     TInt activeIndex = KErrNotFound;
       
  8067                 
       
  8068     if(iPrimaryCandidate && IsQwerty() && ( KeyboardLayout() != EPtiKeyboardHalfQwerty))
       
  8069         {           
       
  8070         iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &activeIndex );        
       
  8071         }
       
  8072             
       
  8073     TInt noOfMatches = iPtiEngine->NumberOfCandidates();
       
  8074     if (noOfMatches > 0)
       
  8075         {
       
  8076         //! The compact candidate popup that opens with when arrow down pressed while inline editing
       
  8077         //MAknFepCandidatePopup *candidatePopup;
       
  8078         
       
  8079         //Predictive QWERTY (XT9) changes for new Architecture ---->
       
  8080         iCandidatePopup = UiInterface()->NewCandidatePopupL(*this);
       
  8081         //Predictive QWERTY (XT9) changes for new Architecture <----
       
  8082             
       
  8083         // Determine the place where to spawn the candidate popup.
       
  8084         TPoint  inlineEditorTl;
       
  8085         TPoint  inlineEditorBr;
       
  8086         TInt    height;
       
  8087         TInt    ascent;
       
  8088         TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
  8089         
       
  8090         //  Popup Position was not right for RTL ---->
       
  8091         if(iLanguageCapabilities.iRightToLeftLanguage)
       
  8092         	documentOffset = 0;
       
  8093         //  Popup Position was not right for RTL <----
       
  8094         GetScreenCoordinatesL(inlineEditorTl, height, ascent, documentOffset);
       
  8095         
       
  8096         inlineEditorTl.iY -= height;
       
  8097         GetScreenCoordinatesL(inlineEditorBr, height, ascent);
       
  8098         
       
  8099         // Focus next word in list ---->
       
  8100         // To fix the bug STAA-7GYDB6, Candidate list opens with the highlight on 3rd candidate when Exact typing is use.
       
  8101         // Show the popup.
       
  8102         TInt selectedIdx = aFocusedIndex;
       
  8103         TKeyEvent lastKeyEvent;
       
  8104         
       
  8105         if(selectedIdx == KErrNotFound)
       
  8106             {
       
  8107             if (noOfMatches > 1)
       
  8108                 {
       
  8109                 selectedIdx = KWordToFocusInCandidateList;
       
  8110                 }
       
  8111             // Focus next word in list <----
       
  8112             if(iSListLaunchedFromMenu)
       
  8113                 {
       
  8114                 iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &selectedIdx );
       
  8115                 iSListLaunchedFromMenu = EFalse;
       
  8116                 }
       
  8117             }
       
  8118         TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8119         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8120         TInt popupCmd = iCandidatePopup->ExecutePopupL( TRect(inlineEditorTl, inlineEditorBr),
       
  8121                                                         selectedIdx, lastKeyEvent, iLanguageCapabilities.iRightToLeftLanguage,
       
  8122                                                         (TInt)KeyboardLayout() );
       
  8123         PrepareFepAfterDialogExitL(fepUid);      
       
  8124         
       
  8125         if((lastKeyEvent.iScanCode == EStdKeyDevice3 ) || 
       
  8126         		((lastKeyEvent.iScanCode == KAknFEPZeroKey)&& ((KeyboardLayout()== EPtiKeyboard12Key)||(KeyboardLayout()==EPtiKeyboardHalfQwerty))) 
       
  8127         		|| lastKeyEvent.iCode == EKeySpace )
       
  8128         	{
       
  8129         	SetExtendedFlag(EExtendedFlagOkKeyPressOnCandidatePopup);
       
  8130         	}
       
  8131        
       
  8132      
       
  8133         TBool needToExecute(EFalse);        
       
  8134         //The candidate list was closed by long key press of shift key
       
  8135         isShiftKeyDepressedAfterCandidateListLaunched = IsFlagSet(EFlagShiftKeyDepressed) && (KeyboardLayout()== EPtiKeyboard12Key);
       
  8136         if (popupCmd != EAknSoftkeyCancel)
       
  8137             {
       
  8138             HandleChangeInFocusL();
       
  8139                               
       
  8140             if (popupCmd == EAknFepSoftkeySpell)
       
  8141                 {                               
       
  8142                 // For QWERTY Input Mode
       
  8143                 if (iQwertyInputMode && EPtiKeyboardHalfQwerty != iKeyboardType) 
       
  8144                     {   
       
  8145                     TInt activeIdx = KErrNotFound;
       
  8146                     TInt secondaryIdx = KErrNotFound;
       
  8147                                     
       
  8148                     iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, 
       
  8149                                                 &activeIdx );
       
  8150                     iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  8151                                                 &secondaryIdx );
       
  8152                     
       
  8153                     if(activeIdx != secondaryIdx)
       
  8154                         {                        
       
  8155                         iPtiEngine->HandleCommandL( 
       
  8156                                  EPtiCommandUserActionSetCurrentIndexOfCandidates, &secondaryIdx );                         
       
  8157                         }
       
  8158                     else
       
  8159                         {
       
  8160                         secondaryIdx = 0;
       
  8161                         iPtiEngine->HandleCommandL( 
       
  8162                                  EPtiCommandUserActionSetCurrentIndexOfCandidates, &secondaryIdx );  
       
  8163                         }
       
  8164                     TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8165                     if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8166                         {
       
  8167                         StartInlineEditingWithSelectedWord(selectedWord);
       
  8168                         }
       
  8169                     UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8170                         
       
  8171                     } 
       
  8172                 // For ITUT Keypad, remove autocompletion part before launching Query Dialog
       
  8173                 else
       
  8174                     {
       
  8175                     RemoveSuggestedAdvanceCompletionL();
       
  8176                     }
       
  8177                 
       
  8178                 // delete the candidate popup before launching the edit word dialog
       
  8179                 // as the candidate list has already been closed.
       
  8180                 if(iCandidatePopup)
       
  8181                     {
       
  8182                     delete iCandidatePopup;
       
  8183                     iCandidatePopup = NULL;
       
  8184                     }
       
  8185                 
       
  8186                 LaunchEditWordQueryL(); 
       
  8187                 }           
       
  8188             
       
  8189             // Close with space or selection key: Commit and add space or move cursor ahead one
       
  8190             // character if next character already is space
       
  8191             else if ( ( lastKeyEvent.iScanCode == EStdKeyDevice3 || lastKeyEvent.iScanCode == KAknFEPZeroKey )
       
  8192             		 && ( KeyboardLayout() == EPtiKeyboard12Key || KeyboardLayout() == EPtiKeyboardHalfQwerty ) )
       
  8193                 {
       
  8194                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8195                                             &selectedIdx ); 
       
  8196                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8197                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8198                     {
       
  8199                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8200                     }
       
  8201                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8202                 iPtiEngine->CommitCurrentWord();
       
  8203                 CommitInlineEditL();
       
  8204 				#ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  8205 				    iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  8206 				#endif    
       
  8207 
       
  8208                 AddOneSpaceOrMoveCursorL();
       
  8209                 }
       
  8210             // Close with right arrow commits the word, does not add space
       
  8211             else if ( lastKeyEvent.iScanCode == EStdKeyRightArrow )
       
  8212             	{
       
  8213                 // Change of UI Spec
       
  8214                 /*
       
  8215                  * The following codde change is a part of bug fix for improper 
       
  8216                  * behavior of right arrow key when the candidate list is open. The
       
  8217                  * right arrow key according to the UI specs should not the selected 
       
  8218                  * candicdate and cursor should be end of the word.
       
  8219                  */
       
  8220                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8221                                             &selectedIdx );               
       
  8222                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8223                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8224                     {
       
  8225                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8226                     }
       
  8227                 UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
  8228                 iPtiEngine->CommitCurrentWord();
       
  8229                 CommitInlineEditL();
       
  8230                 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  8231 				    iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  8232 				#endif  
       
  8233 
       
  8234                 SimulateKeyEventL(EKeyF19);
       
  8235                 }
       
  8236             else if(popupCmd == EAknSoftkeyOk)
       
  8237                 {
       
  8238                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8239                                             &selectedIdx ); 
       
  8240                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8241                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8242                     {
       
  8243                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8244                     }
       
  8245                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8246                 iPtiEngine->CommitCurrentWord();
       
  8247                 CommitInlineEditL();
       
  8248                 AddOneSpaceOrMoveCursorL();
       
  8249                 }
       
  8250             else
       
  8251                 {
       
  8252                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8253                                             &selectedIdx ); 
       
  8254                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8255                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8256                     {
       
  8257                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8258                     }
       
  8259                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8260                 needToExecute = ETrue;
       
  8261                 }
       
  8262             }
       
  8263         else if (popupCmd == EAknSoftkeyCancel && iPrimaryCandidate && IsQwerty() 
       
  8264 				             && ( KeyboardLayout() != EPtiKeyboardHalfQwerty ) )
       
  8265             {
       
  8266             iPtiEngine->HandleCommandL( EPtiCommandUserActionSetIndexOfActiveCandidate, &activeIndex );             
       
  8267             iKeyBackSpaceHit = 0;
       
  8268             }            
       
  8269 		else if(lastKeyEvent.iCode == EKeyPhoneEnd )
       
  8270 			{
       
  8271 			HandleChangeInFocusL();
       
  8272 			CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8273 			}		
       
  8274 	    else if (popupCmd == EAknSoftkeyCancel && IsQwerty() && ( KeyboardLayout() != EPtiKeyboardHalfQwerty ) ) 
       
  8275            iKeyBackSpaceHit = 0;
       
  8276 		
       
  8277         // If the dialog is not closed by pressing softkeys, escape, or right arrow
       
  8278         // then the pressed key is handled also by Fep. This way the user can keep typing when the popup is open.
       
  8279       
       
  8280         //=============== Error fixing and simplify the condition ==========================================
       
  8281         // The following piece of code should be excuted, if focus word
       
  8282         // in the candidate list is accept, otherwise word sholud remain as it is.
       
  8283         // If user does not accept the word,popupCmd always be EAknSoftkeyCancel.
       
  8284         // Insetead of earlier lengthy condition, makes it simple.
       
  8285            
       
  8286         if( needToExecute )
       
  8287            {
       
  8288             const TBool shifted = (lastKeyEvent.iModifiers & (EModifierLeftShift | 
       
  8289                                    EModifierRightShift | EModifierShift));
       
  8290             const TBool chrDown = (lastKeyEvent.iModifiers & (EModifierLeftFunc));                       
       
  8291             
       
  8292             const TBool fnDown = (lastKeyEvent.iModifiers & (EModifierRightFunc));                       
       
  8293             if(fnDown  ) 
       
  8294                 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyDown)  ;     
       
  8295 
       
  8296          	if (shifted)
       
  8297           		{
       
  8298           		SetFlag(EFlagQwertyShiftMode|EFlagNoActionDuringShiftKeyPress);
       
  8299           		}
       
  8300             else
       
  8301                 {
       
  8302                 ClearFlag(EFlagQwertyShiftMode|EFlagNoActionDuringShiftKeyPress);
       
  8303                 }
       
  8304             
       
  8305             if (chrDown)
       
  8306                 {
       
  8307                 SetFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress);
       
  8308                 }
       
  8309             else
       
  8310                 {
       
  8311                 ClearFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress);
       
  8312                 }
       
  8313             if ( lastKeyEvent.iScanCode == EStdKeyDevice3 )
       
  8314                 {
       
  8315                 CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8316                 }
       
  8317             if (! ( lastKeyEvent.iScanCode == EStdKeyDevice3 || 
       
  8318                     lastKeyEvent.iScanCode == EStdKeyRightArrow ) )
       
  8319                 {
       
  8320                 /*
       
  8321                  * The following code change is a part of bug fix for improper 
       
  8322                  * behavior of any keypress when the candidate list is open. The
       
  8323                  * keypress according to the UI specs should lock the selected 
       
  8324                  * candidate to editor and the inserted letter is appended to it. 
       
  8325                  */                
       
  8326                 iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate);
       
  8327                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8328                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8329                     {
       
  8330                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8331                     }
       
  8332                 UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
  8333                 // For QWERTY input mode, scanCode is used
       
  8334 			#ifdef __HALF_QWERTY_KEYPAD
       
  8335                 if( KeyboardLayout() == EPtiKeyboardHalfQwerty)
       
  8336                     {
       
  8337                     iHalfQwertyLastKeyEvent = lastKeyEvent;
       
  8338                     iAsyncOwnSimulateKey.CallBack();                    
       
  8339                     }
       
  8340                 else 
       
  8341 			#endif //__HALF_QWERTY_KEYPAD
       
  8342                 if (iQwertyInputMode)
       
  8343                     {
       
  8344                     CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8345                     }
       
  8346                 // For ITUT input Mode, keyCode is used
       
  8347                 else
       
  8348                     {
       
  8349                     SimulateKeyEventL( lastKeyEvent.iCode);
       
  8350                     }
       
  8351                 }
       
  8352             }
       
  8353             
       
  8354         ShowExactWordPopupIfNecessaryL();
       
  8355         if(iCandidatePopup)
       
  8356             {
       
  8357             delete iCandidatePopup;
       
  8358             iCandidatePopup = NULL;
       
  8359             }
       
  8360         }
       
  8361     //The flag ECcpuStateShiftkeyWasPressedBeforeLosingFocus suggests that the candidate list was closed with a 
       
  8362     //long key press of edit key (shift key). There are multiple calls to HandleChangedInFocusL() one manually and the other  through
       
  8363     //CONE focus change notifier. We want the flag to be set for CONE's focus handler.
       
  8364     if(isShiftKeyDepressedAfterCandidateListLaunched)
       
  8365         {
       
  8366         SetCcpuFlag(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  8367         }
       
  8368     }
       
  8369 void CAknFepManager::StartInlineEditingWithSelectedWord(TDesC& aTextToUncommit)
       
  8370     {
       
  8371     if(iConcatenationTimer->IsActive())
       
  8372     	iConcatenationTimer->Cancel();
       
  8373 	
       
  8374     TInt docLenFep=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  8375                 if (iUncommittedText.iCursorPos>docLenFep)
       
  8376                     iUncommittedText.iCursorPos=docLenFep;
       
  8377                 if (iUncommittedText.iAnchorPos>docLenFep)
       
  8378                     iUncommittedText.iAnchorPos=docLenFep;
       
  8379                         // Activates western predictive UI to an inline editing state.
       
  8380                 FepUI()->ActivateUI();
       
  8381                 SyncStates(EAknFepStateUIActive);
       
  8382                   // Predictive QWERTY (XT9) changes <----
       
  8383                 TRAP_IGNORE(StartInlineEditL(iUncommittedText, aTextToUncommit,
       
  8384                         aTextToUncommit.Length(), EFalse));
       
  8385 
       
  8386     }
       
  8387 void CAknFepManager::ShowExactWordPopupIfNecessaryL()
       
  8388     {
       
  8389     iExactWordPopupContent->HidePopUp();
       
  8390     
       
  8391     // Before open tooltip,  
       
  8392     // also need to check and close tooltip on it.
       
  8393     SendEventsToPluginManL( EPluginHideTooltip );
       
  8394     
       
  8395     if ( iWesternPredictive && iQwertyInputMode 
       
  8396     	 && IsFlagSet( EFlagInsideInlineEditingTransaction ) 
       
  8397     	 && (EPtiKeyboardHalfQwerty != KeyboardLayout()))
       
  8398         {
       
  8399         // In the proactive mode this popup is used to show the exact input if it differs from the
       
  8400         // default candidate shown inline.
       
  8401         // In the reactive mode it is used to show the best guess candidate if it differs from the
       
  8402         // exact word shown inline.
       
  8403         
       
  8404         TInt activeIdx = KErrNotFound;
       
  8405         TInt secondaryIdx = KErrNotFound;
       
  8406                      
       
  8407         iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &activeIdx );
       
  8408         iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  8409         							&secondaryIdx );
       
  8410         
       
  8411         TBool popupBelowInline = EFalse; // ETrue -> popup is above inline editor                                                                   
       
  8412                 
       
  8413        if(iKeyBackSpaceHit)
       
  8414     	    secondaryIdx = activeIdx;
       
  8415 
       
  8416         if ( activeIdx  != secondaryIdx )
       
  8417             {
       
  8418             popupBelowInline = EFalse;
       
  8419             
       
  8420             CDesCArray* candidates = new (ELeave) CDesCArrayFlat(16);
       
  8421             CleanupStack::PushL(candidates);
       
  8422             GetCandidatesL(*candidates, activeIdx);
       
  8423             
       
  8424             // There is a possibility that the secondary index of the candidate changes
       
  8425             iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  8426                                         &secondaryIdx );
       
  8427             // In case the active index and the secondary index is same, then we do not need to display the
       
  8428             // popup
       
  8429             if ( activeIdx  == secondaryIdx )
       
  8430                 {
       
  8431                 CleanupStack::PopAndDestroy(candidates);
       
  8432                 return;
       
  8433                 }
       
  8434             
       
  8435             TPtrC secondaryWord = (*candidates)[secondaryIdx];
       
  8436             iExactWordPopupContent->SetTextL( secondaryWord );
       
  8437             iExactWordPopupContent->SetArrowDirection( MAknFepUiWordPopupContent::EUpwards );
       
  8438             CleanupStack::PopAndDestroy(candidates);
       
  8439 
       
  8440             // Open FSQ tooltip if FSQ is opened
       
  8441      	    SendEventsToPluginManL( EPluginShowTooltip, secondaryIdx );
       
  8442 
       
  8443           
       
  8444             // For addtion of ITI features on FSQ.
       
  8445             // Showing tooltip on avkon editor and FSQ ICF editor at same time probably 
       
  8446             // cause flicker problem. Add this condition to ensure not to show tooltip on
       
  8447             // avkon editor when it is being displayed on FSQ.
       
  8448             if ( iFepPluginManager && !( iFepPluginManager->IsTooltipOpenOnFSQ() ) )
       
  8449                 {
       
  8450                 TPoint  popupTopRight;
       
  8451                 TInt    height;
       
  8452                 TInt    ascent;
       
  8453                 TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
  8454                 
       
  8455                 GetScreenCoordinatesL(popupTopRight, height, ascent, documentOffset);
       
  8456 
       
  8457                 iExactWordPopupContent->UpdateContentSize();
       
  8458 
       
  8459                 TBool rightToLeftLang = IsRightToLeftParagraph( DocPos() );
       
  8460                 if ( !rightToLeftLang )
       
  8461                     {
       
  8462                     popupTopRight.iX += iExactWordPopupContent->Size().iWidth;       
       
  8463                     }
       
  8464                     
       
  8465                 if ( popupBelowInline )
       
  8466                     {
       
  8467                     popupTopRight.iY += ascent / 2;                                   
       
  8468                     }
       
  8469                 else
       
  8470                     {
       
  8471                     popupTopRight.iY -= height + iExactWordPopupContent->Size().iHeight;
       
  8472                     }
       
  8473                     
       
  8474                 iExactWordPopupContent->SetPosition( popupTopRight );
       
  8475                 iExactWordPopupContent->ShowPopUp();         
       
  8476                 }                
       
  8477             }  
       
  8478         }
       
  8479 		else if(iWesternPredictive 
       
  8480     	 && IsFlagSet( EFlagInsideInlineEditingTransaction ) 
       
  8481     	 && IsFlagSet(CAknFepManager::EFlagNoMatches)) 
       
  8482     	{
       
  8483     	UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY);
       
  8484     	}
       
  8485     }
       
  8486 
       
  8487 void CAknFepManager::LaunchPredictiveSettingDialogL()
       
  8488 	{
       
  8489 #ifdef RD_SCALABLE_UI_V2	
       
  8490     // Addtion of ITI features on FSQ.
       
  8491     if ( iFepPluginManager 
       
  8492          && iFepPluginManager->IsSupportITIOnFSQ() )
       
  8493         {
       
  8494         // Hide touch input ui firstly,
       
  8495         // otherwise, touch ui can hide status pane.        
       
  8496         // Let CAknFepPluginManager know this setting dialog will be opened.
       
  8497         iFepPluginManager->ITISettingDialogOpen( ETrue );
       
  8498         iFepPluginManager->ClosePluginInputUiL( ETrue );
       
  8499         SendEventsToPluginManL( ELostForeground );
       
  8500         }
       
  8501 #endif // RD_SCALABLE_UI_V2
       
  8502 
       
  8503 	// Hide fixed toolbar just before launching predictive settings dialog
       
  8504 	CEikAppUiFactory * appUiFactory = NULL;
       
  8505 	appUiFactory = static_cast<CEikAppUiFactory*>(CEikonEnv::Static()->AppUiFactory());
       
  8506 	
       
  8507 	CAknToolbar * fixedToolbar = NULL;
       
  8508 	if(appUiFactory)
       
  8509 	    fixedToolbar = appUiFactory->CurrentFixedToolbar();
       
  8510 	
       
  8511 	// If fixedtoolbar is not there in the current editor, we don't need to hide it before launching settings dialog 
       
  8512 	// and unhide it after settings dialog is done.
       
  8513 	if( fixedToolbar && !( fixedToolbar->IsShown() && fixedToolbar->CountComponentControls()>0 ) )
       
  8514 	    fixedToolbar = NULL;
       
  8515 	
       
  8516 	if(fixedToolbar)
       
  8517 		{
       
  8518 	  fixedToolbar->SetDimmed(ETrue);
       
  8519 	  fixedToolbar->DrawDeferred();
       
  8520 	  }
       
  8521     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8522     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8523 	UiInterface()->LaunchPredictiveSettingDialogL(R_PREDICTIVESETTING_DIALOG,
       
  8524 												  R_PREDICTIVESETTINGDIALOG_MENUBAR,
       
  8525 												  R_PREDICTIVETEXTOFF_CONFIRMATION_QUERY,
       
  8526 												  R_AKNFEP_PRED_INPUT_SETTINGS_TITLE);
       
  8527     PrepareFepAfterDialogExitL(fepUid);	
       
  8528 #ifdef RD_SCALABLE_UI_V2	
       
  8529     // // Addtion of ITI features on FSQ.    
       
  8530     if ( iFepPluginManager 
       
  8531          && iFepPluginManager->IsSupportITIOnFSQ() )
       
  8532         {        
       
  8533         // Let CAknFepPluginManager know this setting dialog will be opened.
       
  8534         iFepPluginManager->ITISettingDialogOpen( EFalse );        
       
  8535         }
       
  8536 #endif // RD_SCALABLE_UI_V2
       
  8537 
       
  8538 	// Enables fixed toolbar after predictive settings dialog is closed
       
  8539 	if(fixedToolbar)
       
  8540 		{
       
  8541 	  fixedToolbar->SetDimmed(EFalse);
       
  8542 	  fixedToolbar->DrawDeferred();
       
  8543 	  }
       
  8544 	}
       
  8545 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
  8546 void CAknFepManager::LaunchWritingLanguageSettingDialogL()
       
  8547     {
       
  8548     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8549     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8550     UiInterface()->LaunchWritingLanguageSettingDialogL(R_INPUTLANGUAGE_DIALOG, R_PREDICTIVESETTINGDIALOG_MENUBAR, R_INPUT_LANGUAGE_SETTINGS_TITLE);
       
  8551     PrepareFepAfterDialogExitL(fepUid);	
       
  8552 	}
       
  8553 
       
  8554 void  CAknFepManager:: LaunchDualLanguageSettingDialogL()
       
  8555     {
       
  8556     /* In Chinese language variant,if there are more than one languages supporting dual language feature,
       
  8557     display writing language setting view in which Primary and Secondary Languages can be selected from the list.
       
  8558     
       
  8559     In Chinese language variant,if there is only one language supporting dual language feature, 
       
  8560     no need to display the Writing language view which contains Primary and Secondary Language. 
       
  8561     Instead we can display the Writing language list directly to the user;from which the user can select the writing language*/
       
  8562 
       
  8563     if( FeatureManager::FeatureSupported( KFeatureIdChinese ) || FeatureManager::FeatureSupported( KFeatureIdJapanese ))
       
  8564         {                        
       
  8565         CArrayFixFlat<TInt>* languages = new( ELeave )CArrayFixFlat<TInt>( ELanguageArrayGranularity );
       
  8566         CleanupStack::PushL( languages );
       
  8567         iPtiEngine->GetAvailableLanguagesL( languages );
       
  8568         
       
  8569         TInt count = languages->Count();   
       
  8570         TInt noLangSupportWesternPred = count;
       
  8571         for (TInt index = 0; index < count; index++)
       
  8572             {      
       
  8573             TInt langCode = languages->At(index);            
       
  8574             
       
  8575             if (langCode == ELangTaiwanChinese ||
       
  8576                langCode == ELangHongKongChinese ||
       
  8577                langCode == ELangPrcChinese ||
       
  8578                langCode == ELangJapanese ||
       
  8579                langCode == ELangKorean )
       
  8580                 {
       
  8581                 noLangSupportWesternPred--;
       
  8582                 }            
       
  8583             }                         
       
  8584         CleanupStack::PopAndDestroy(languages);    
       
  8585         
       
  8586         if( noLangSupportWesternPred > 1 )
       
  8587             {             
       
  8588             SetFlag(CAknFepManager::EFlagNewSharedDataInputMode);
       
  8589             LaunchWritingLanguageSettingDialogL();            
       
  8590             if(IsFlagSet(CAknFepManager::EFlagNewSharedDataInputLanguage))
       
  8591                 {
       
  8592                 ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
  8593                 HandleChangeInFocusL();
       
  8594                 ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  8595                 }
       
  8596             }
       
  8597         else
       
  8598             LaunchLanguagesPopupListL();                                                
       
  8599         }   
       
  8600     else
       
  8601         {
       
  8602         LaunchWritingLanguageSettingDialogL();        
       
  8603         if(IsFlagSet(CAknFepManager::EFlagNewSharedDataInputLanguage))
       
  8604             {
       
  8605             ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
  8606             HandleChangeInFocusL();
       
  8607             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  8608             }
       
  8609         } 
       
  8610         
       
  8611     }
       
  8612 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  8613 // Predictive QWERTY (XT9) changes <----
       
  8614 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  8615 void CAknFepManager::LaunchInsertWordQueryL(const TDesC& aInitialText, 
       
  8616                                             TCursorSelection aTextSpanToReplace)
       
  8617     {
       
  8618     TInt recourceId;
       
  8619     if(EditorState()->Flags() & EAknEditorFlagEnablePartialScreen)
       
  8620         {
       
  8621         recourceId = R_AVKON_INSERT_WORD_FS_QUERY;
       
  8622         }
       
  8623     else
       
  8624         {
       
  8625         recourceId = R_AVKON_INSERT_WORD_QUERY;
       
  8626         }
       
  8627     LaunchFepQueryDialogL(recourceId, aInitialText, aTextSpanToReplace);
       
  8628     }
       
  8629 
       
  8630 void CAknFepManager::LaunchEditWordQueryL()
       
  8631     {
       
  8632 
       
  8633     TBuf<EMaximumFepWordLength> newText;
       
  8634 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8635 	if(IsAutoCompleteOn())
       
  8636   		{
       
  8637         RemoveSuggestedCompletionL();
       
  8638         }
       
  8639 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  8640     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
  8641                                                                     iUncommittedText.iAnchorPos, 
       
  8642                                                                     iUncommittedText.Length());
       
  8643 
       
  8644     TInt recourceId;
       
  8645     if(EditorState()->Flags() & EAknEditorFlagEnablePartialScreen)
       
  8646         {
       
  8647         recourceId = R_AVKON_INSERT_WORD_FS_QUERY;
       
  8648         }
       
  8649     else
       
  8650         {
       
  8651         recourceId = R_AVKON_INSERT_WORD_QUERY;
       
  8652         }
       
  8653     LaunchFepQueryDialogL(recourceId, newText, iUncommittedText);
       
  8654     }
       
  8655 
       
  8656 void CAknFepManager::LaunchFepQueryDialogL(TInt aResourceId, const TDesC& aInitialText, 
       
  8657                                            TCursorSelection aTextSpanToReplace)
       
  8658     {
       
  8659     HBufC* textBuf = HBufC::NewLC(EQueryBufferLength);  // buffer for inserted text
       
  8660     TPtr text = textBuf->Des();
       
  8661 
       
  8662     if (aInitialText.Length() <= EQueryBufferLength)
       
  8663         text.Copy(aInitialText);
       
  8664     else // truncate the incoming text to EQueryBufferLength before copying
       
  8665         {
       
  8666         TPtrC truncatedText = aInitialText.Left(EQueryBufferLength);
       
  8667         text.Copy(truncatedText);
       
  8668         }
       
  8669 
       
  8670     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8671         {
       
  8672         TryRemoveNoMatchesIndicatorL();
       
  8673         CommitInlineEditL();
       
  8674         }
       
  8675     UpdateCbaL(NULL);
       
  8676 
       
  8677     TInt underlyingCase = iCaseMan->CurrentCase();
       
  8678     TBool isCaseUpdatesSupressed = IsFlagSet(EFlagSupressAutoUpdateAtEditorStart);
       
  8679 
       
  8680 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8681     if (aInitialText.Length())
       
  8682         {
       
  8683         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  8684         if (aInitialText.Length() == 1)
       
  8685             {
       
  8686             if (STATIC_CAST(TChar, aInitialText[0]).IsUpper())
       
  8687                 iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  8688             }
       
  8689         else // length of initial text > 1
       
  8690             {
       
  8691             if (STATIC_CAST(TChar, aInitialText[0]).IsUpper())
       
  8692                 {
       
  8693                 if (STATIC_CAST(TChar, aInitialText[1]).IsLower())
       
  8694                     iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  8695                 else // 2nd character is upper case
       
  8696                     iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  8697                 }
       
  8698             }
       
  8699         }
       
  8700 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  8701 
       
  8702     if (iCaseMan->CurrentCase() == EAknEditorLowerCase 
       
  8703      || iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  8704         {
       
  8705         SetFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  8706         }
       
  8707 
       
  8708     TransferFepStateToEditorL();
       
  8709 
       
  8710     SetFlag(EFlagForegroundUIComponentVisible);
       
  8711     
       
  8712     TInt textQueryEditorFlag = 0;
       
  8713     if ((aResourceId == R_AVKON_INSERT_WORD_QUERY ||
       
  8714          aResourceId == R_AVKON_EDIT_WORD_QUERY ) &&
       
  8715         IsChineseInputLanguage())
       
  8716     	{
       
  8717 	    textQueryEditorFlag = EAknEditorFlagLatinInputModesOnly;
       
  8718     	}
       
  8719 #ifdef RD_SCALABLE_UI_V2     
       
  8720     if (iFepFullyConstructed && 
       
  8721         iFepPluginManager->PluginInputMode() == EPluginInputModeItut && 
       
  8722         !(EditorState()->Flags() & EAknEditorFlagEnablePartialScreen))
       
  8723         {
       
  8724         iFepPluginManager->SpellText(textBuf);
       
  8725         iFepPluginManager->DisplaySpellEditor(textQueryEditorFlag, aInitialText, 
       
  8726                                               TCursorSelection(aInitialText.Length(), 0));
       
  8727 
       
  8728         delete iSpellInitText;
       
  8729         iSpellInitText = NULL;
       
  8730 	    iSpellInitText = aInitialText.AllocL();
       
  8731 	    iSpellInitCurSel = aTextSpanToReplace;
       
  8732 
       
  8733         iFepPluginManager->SetCaseUpdatesSupressed(isCaseUpdatesSupressed);
       
  8734         iFepPluginManager->SetITUTSpellingStateL(ETrue);    
       
  8735         iFepPluginManager->SetCursorSelection(aTextSpanToReplace);
       
  8736         CleanupStack::PopAndDestroy();
       
  8737         
       
  8738         return;
       
  8739         }
       
  8740 #endif    
       
  8741     
       
  8742     if(iFepPluginManager)
       
  8743         {
       
  8744         iFepPluginManager->SetInEditWordQueryFlag(ETrue);
       
  8745         }
       
  8746 
       
  8747     PrepareFepForFepAwareDialogLaunch();
       
  8748     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8749     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8750     TInt id = iUiInterface->TextQueryDialogL(text, *EditorState(), 
       
  8751                                              textQueryEditorFlag, aResourceId);
       
  8752     PrepareFepAfterFepAwareDialogExitL(fepUid);        
       
  8753     PrepareFepAfterDialogExitL(fepUid);
       
  8754 
       
  8755     if(iFepPluginManager)
       
  8756         {
       
  8757         iFepPluginManager->SetInEditWordQueryFlag(EFalse);
       
  8758         }                                             
       
  8759     if (id == EAknSoftkeyOk)
       
  8760         {
       
  8761         // Insert the character into the edwin.
       
  8762         InsertTextFromDialogL(text, aTextSpanToReplace);
       
  8763         // Add the word to the user dictionary (except for single character)  after it has been added to the editor.
       
  8764         // FepUI of the main editor is used. Different FepUI is used in multitap
       
  8765         // query and predictive mode 'main' editor at least in Japanese variant.
       
  8766 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  8767         if(text.Length() > 1)
       
  8768             FepUI()->AddTextToUserDictionaryL(text);
       
  8769 #else
       
  8770         FepUI()->AddTextToUserDictionaryL(text); 
       
  8771 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  8772 
       
  8773         }
       
  8774     else // restore original case and inline text
       
  8775         {
       
  8776         HandleChangeInFocus();
       
  8777         if (aTextSpanToReplace.Length())
       
  8778             {
       
  8779             EditorState()->SetInlineEditSpan(aTextSpanToReplace);
       
  8780             ConfigureFEPFromEditorStateL();
       
  8781             }
       
  8782         iCaseMan->SetCurrentCase(underlyingCase);
       
  8783         TransferFepStateToEditorL();
       
  8784         }
       
  8785 
       
  8786     if (isCaseUpdatesSupressed)
       
  8787         {
       
  8788         SetFlag(EFlagSupressAutoUpdate);
       
  8789         }
       
  8790     else
       
  8791         {
       
  8792         ClearFlag(EFlagSupressAutoUpdate);
       
  8793         }
       
  8794     ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  8795     CleanupStack::PopAndDestroy(); // text
       
  8796     }
       
  8797 
       
  8798 void CAknFepManager::InsertTextFromDialogL(const TDesC& aTextFromDialog, 
       
  8799                                            TCursorSelection aExtentOfTextToReplace)
       
  8800     {
       
  8801     SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  8802     // ensure we're back on the correct editor
       
  8803  
       
  8804 #ifdef RD_SCALABLE_UI_V2   
       
  8805     iNotifyPlugin = EFalse; // not really focus change
       
  8806     HandleChangeInFocus();
       
  8807     iNotifyPlugin = ETrue;
       
  8808 #else
       
  8809     HandleChangeInFocus();
       
  8810 #endif    
       
  8811     // need to commit if the editor was previously performing an inline edit
       
  8812     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8813         CommitInlineEditL();
       
  8814 
       
  8815     TInt addedTextLength=0;
       
  8816 
       
  8817     TCursorSelection currentSelection;
       
  8818 // In case input capabilities goes null leaving with an error code and allowing application to handle..
       
  8819     if (NULL == iInputCapabilities.FepAwareTextEditor())
       
  8820         User::Leave(KErrCorrupt);
       
  8821     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelection);
       
  8822     // Prepare for the edit
       
  8823     TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  8824     TInt maxLength = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
  8825 
       
  8826     if (aExtentOfTextToReplace.Length())
       
  8827         {
       
  8828         if (currentSelection.Length())
       
  8829             // Want to 'cancel' the selection so move cursor & anchor to the end of
       
  8830             // the selection and then to the end of the current word
       
  8831             {
       
  8832             TInt endOfSelection=currentSelection.HigherPos();
       
  8833             iUncommittedText.SetSelection(endOfSelection, endOfSelection);
       
  8834             if (CursorInsideWord())
       
  8835                 MoveCursorToEndOfWordL();
       
  8836             }
       
  8837         iUncommittedText = aExtentOfTextToReplace;
       
  8838         iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
  8839         addedTextLength = aTextFromDialog.Length();
       
  8840         if (maxLength != 0)
       
  8841             {
       
  8842             addedTextLength = Min(addedTextLength,
       
  8843                 (maxLength - docLength + iUncommittedText.Length()));
       
  8844             }
       
  8845         }
       
  8846     else
       
  8847         {
       
  8848         addedTextLength = aTextFromDialog.Length();
       
  8849 
       
  8850         //maxLength of 0 means the editor has no limit
       
  8851         if (maxLength != 0)
       
  8852             {
       
  8853             addedTextLength = Min(addedTextLength,
       
  8854                                   (maxLength - docLength + currentSelection.Length()));
       
  8855             }
       
  8856         if (currentSelection.Length())
       
  8857             {
       
  8858             iUncommittedText.SetSelection(currentSelection.HigherPos(), 
       
  8859                                           currentSelection.LowerPos());
       
  8860             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
  8861             }
       
  8862         else // do this in order for editor to get the correct number of chars to format from GetFormatOfFepInlineText()
       
  8863             iUncommittedText.iCursorPos+=addedTextLength;
       
  8864         }
       
  8865     // if necessary trim text to fit into available space in the editor & perform the edit
       
  8866     TPtrC textToEditor = aTextFromDialog.Left(addedTextLength);
       
  8867 
       
  8868     StartInlineEditL(textToEditor);
       
  8869     CommitInlineEditL();
       
  8870 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  8871     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  8872 #endif    
       
  8873 
       
  8874     EditorState()->SetInlineEditSpan(iUncommittedText);
       
  8875     }
       
  8876 
       
  8877 void CAknFepManager::LaunchKutenCodeQueryL()
       
  8878     {
       
  8879     TInt code;
       
  8880     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8881     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8882     UiInterface()->JapaneseKutenQueryDialogL(R_AKNFEPUICTRLJAPANESEKUTEN_QUERY, code, 0);
       
  8883 
       
  8884     PrepareFepAfterDialogExitL(fepUid);
       
  8885 
       
  8886     HandleChangeInFocus();  // to re-establish contact with editor under KutenCode Query
       
  8887 
       
  8888     if (code > 0 && EditorHasFreeSpace())
       
  8889         {
       
  8890         TBuf<ESingleCharacter> text;
       
  8891         text.Append((TText)code);
       
  8892         SetFlag(EFlagInsideInlineEditingTransaction);
       
  8893         iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(text, ESingleCharacter, 
       
  8894                                                                      ETrue, NULL, *this, *this);
       
  8895         CommitInlineEditL();
       
  8896         }
       
  8897     }
       
  8898 
       
  8899 TInt CAknFepManager::NumericModeSCTResourceId() const
       
  8900     {
       
  8901     TInt charMapResId = EDefaultNumericCharMapResId;
       
  8902     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);            
       
  8903     
       
  8904     if( phoneIdle )
       
  8905         {
       
  8906         charMapResId=R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  8907         return charMapResId;
       
  8908         }
       
  8909 
       
  8910     switch (iAknEditorNumericKeymap)
       
  8911         {
       
  8912         case EAknEditorStandardNumberModeKeymap:
       
  8913             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  8914             break;
       
  8915         case EAknEditorCalculatorNumberModeKeymap:
       
  8916             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_CALCULATOR;
       
  8917             break;
       
  8918         case EAknEditorConverterNumberModeKeymap:
       
  8919             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_CONVERTER;
       
  8920             break;
       
  8921         case EAknEditorFixedDiallingNumberModeKeymap:
       
  8922             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_FIXED_DIALLING;
       
  8923             break;
       
  8924         case EAknEditorSATNumberModeKeymap:
       
  8925             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_SAT;
       
  8926             break;
       
  8927         case EAknEditorToFieldNumberModeKeymap:
       
  8928             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_TO_FIELD;
       
  8929             break;
       
  8930         case EAknEditorPlainNumberModeKeymap:
       
  8931             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_PLAIN;
       
  8932             break;
       
  8933         case EAknEditorNativeKeysNumberModeKeymap:
       
  8934             //currently this is not in use
       
  8935             break;
       
  8936         case EAknEditorSATHiddenNumberModeKeymap:
       
  8937             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_SAT_HIDDEN;
       
  8938             break;
       
  8939         default:
       
  8940             //We reach here because there is no valid SCT resource ID set
       
  8941             //by the current editor. So best we can do now is set the 
       
  8942             //default mode for numeric editors.
       
  8943             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  8944             break;
       
  8945         }
       
  8946     if(IsHybridAplhaEditor() && !IsHybridAlphaModeChangedtoAplhanumeric())
       
  8947         {
       
  8948         charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  8949         }
       
  8950     return charMapResId;
       
  8951     }
       
  8952 
       
  8953 
       
  8954 TBool CAknFepManager::HashKeyModeChangeBlockedInSearchField() const
       
  8955     {
       
  8956     if ((iAknEditorFlags & EAknEditorFlagFindPane) && 
       
  8957          iSharedDataInterface->HashKeySelectionInUse() &&                
       
  8958          !IsChineseInputLanguage() &&
       
  8959          !IsKoreanInputLanguage() &&
       
  8960          iLanguageCapabilities.iInputLanguageCode != ELangVietnamese &&
       
  8961          !FeatureManager::FeatureSupported(KFeatureIdJapanese))
       
  8962          {
       
  8963          if (iMode == ELatin || iMode == ENumber || iMode == ENativeNumber )
       
  8964             {
       
  8965             return ETrue;               
       
  8966             }                               
       
  8967          }
       
  8968              
       
  8969     return EFalse;         
       
  8970     }
       
  8971 
       
  8972     
       
  8973 TKeyResponse CAknFepManager::HandleHashKeyL(TKeyPressLength aLength)
       
  8974     {
       
  8975     TKeyResponse response = EKeyWasNotConsumed;
       
  8976     if (IsFlagSet(EFlagPassNextKey))
       
  8977         {
       
  8978         ClearFlag(EFlagPassNextKey);
       
  8979         }
       
  8980     else if (IsFlagSet(EFlagShiftKeyDepressed))
       
  8981         {
       
  8982         response = EKeyWasConsumed;
       
  8983         }
       
  8984     else if (HashKeyModeChangeBlockedInSearchField())      
       
  8985         {
       
  8986         // Do not allow case changes for latin languages in search field
       
  8987         // if hash key selection is active.
       
  8988         response = EKeyWasConsumed;
       
  8989         }
       
  8990     else
       
  8991         {
       
  8992         if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  8993             {
       
  8994 #ifdef RD_HINDI_PHONETIC_INPUT	                    
       
  8995 		if(iSharedDataInterface->InputTextLanguage() != KLangHindiPhonetic)    
       
  8996 #endif            
       
  8997             FepUI()->ExpireMultitapTimer();
       
  8998             // For Japanese, send backspace key event in case hash key
       
  8999             // is pressed while secret text input.
       
  9000            if (IsFeatureSupportedJapanese())
       
  9001                 {
       
  9002                 if (iInputCapabilities.SupportsSecretText())
       
  9003                     {
       
  9004                     SimulateKeyEventL(EKeyF20);          //backspace
       
  9005                     }
       
  9006                 }
       
  9007 #ifdef RD_HINDI_PHONETIC_INPUT	                    
       
  9008 		if(iSharedDataInterface->InputTextLanguage() != KLangHindiPhonetic)    
       
  9009 #endif            
       
  9010                 ClearFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9011             iCaseMan->UpdateCase(ENullNaviEvent);
       
  9012             }
       
  9013         if (aLength == EShortKeyPress)
       
  9014             {
       
  9015             if ( iMode != ENumber && iMode != ENativeNumber )
       
  9016                 {
       
  9017                 iModeBefore = iMode;
       
  9018                 if (iModeBefore == ELatin)
       
  9019                     {
       
  9020                     iCaseBefore = iCaseMan->CurrentCase();
       
  9021                     }
       
  9022                 }
       
  9023             }
       
  9024 
       
  9025        // always keep previous input mode for Japanese input
       
  9026        if (IsFeatureSupportedJapanese())
       
  9027             {
       
  9028             iModeBefore = iMode;
       
  9029             if (iModeBefore == ELatin)
       
  9030                 {
       
  9031                 iCaseBefore = iCaseMan->CurrentCase();
       
  9032                 }
       
  9033             }
       
  9034        if (iMode == EHangul && aLength == ELongKeyPress)
       
  9035        		{       
       
  9036        		if (IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
  9037                 {
       
  9038                 TPtrC text = iPtiEngine->CurrentWord();
       
  9039                 if (text.Length() > 0)
       
  9040             		{
       
  9041             		CancelInlineEdit();
       
  9042             		StartInlineEditL();
       
  9043             		UpdateInlineEditL(iPtiEngine->PreviousCandidate(), iPtiEngine->PreviousCandidate().Length());
       
  9044             		CommitInlineEditL();
       
  9045             		}
       
  9046             	else
       
  9047             		{
       
  9048             		CancelInlineEdit();          		
       
  9049             		}
       
  9050             	iPtiEngine->ClearCurrentWord();
       
  9051                 }
       
  9052        		}
       
  9053 		
       
  9054         response = iHashKeyMan->HandleKeyEventL(aLength);
       
  9055         if (response == EKeyWasNotConsumed)
       
  9056             {
       
  9057             switch (iAknEditorNumericKeymap)
       
  9058                 {
       
  9059             case EAknEditorStandardNumberModeKeymap: //fall through
       
  9060             case EAknEditorFixedDiallingNumberModeKeymap:
       
  9061             case EAknEditorSATNumberModeKeymap:
       
  9062             case EAknEditorSATHiddenNumberModeKeymap:
       
  9063             case EAknEditorAlphanumericNumberModeKeymap:
       
  9064                 if (!EditorHasFreeSpace())
       
  9065                     {
       
  9066                     response=EKeyWasConsumed;
       
  9067                     }
       
  9068                 break;
       
  9069             case EAknEditorCalculatorNumberModeKeymap: //fall through
       
  9070             case EAknEditorConverterNumberModeKeymap:
       
  9071                 SimulateKeyEventL(CurrentDecimalSeparator());
       
  9072                 if (EditorHasFreeSpace())
       
  9073                     {
       
  9074                     SetFlag(EFlagCharacterAdded);
       
  9075                     }
       
  9076                 response=EKeyWasConsumed;
       
  9077                 break;
       
  9078             case EAknEditorToFieldNumberModeKeymap:
       
  9079                 SimulateKeyEventL(text_to_field_mode_hash_key);
       
  9080                 if (EditorHasFreeSpace())
       
  9081                     {
       
  9082                     SetFlag(EFlagCharacterAdded);
       
  9083                     }
       
  9084                 response=EKeyWasConsumed;
       
  9085                 break;
       
  9086             case EAknEditorPlainNumberModeKeymap:
       
  9087                 response=EKeyWasConsumed;
       
  9088                 break;
       
  9089             case EAknEditorNativeKeysNumberModeKeymap:
       
  9090                 break;
       
  9091             default:
       
  9092                 break;
       
  9093                 }
       
  9094             }
       
  9095         }
       
  9096     return response;
       
  9097     }
       
  9098 
       
  9099 TInt CAknFepManager::EditorNumericKeymap() const
       
  9100     {
       
  9101     return iAknEditorNumericKeymap;
       
  9102     }
       
  9103 
       
  9104 
       
  9105 TBool CAknFepManager::HashKeySelectionInUse() const
       
  9106     {       
       
  9107 	if (ExtendedInputCapabilities() 
       
  9108     & CAknExtendedInputCapabilities::EForceHashKeySelectionStatusFlagOff)
       
  9109 	    {
       
  9110 	    return EFalse;
       
  9111 	    }
       
  9112         
       
  9113     return iSharedDataInterface->HashKeySelectionInUse();           
       
  9114     }     
       
  9115   
       
  9116 
       
  9117 TBool CAknFepManager::EditSubmenuInUse() const
       
  9118 	{
       
  9119 	if (RProcess().SecureId().iId == KPhoneSecureId)
       
  9120 		{
       
  9121 		if (iQwertyInputMode)
       
  9122 			{
       
  9123 			return EFalse;				
       
  9124 			}
       
  9125 		} 
       
  9126 			
       
  9127 	if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff)
       
  9128 	    {
       
  9129 	    return EFalse;
       
  9130 	    }			
       
  9131 			
       
  9132 	return iSharedDataInterface->EditSubmenuInUse();			
       
  9133 	} 
       
  9134 
       
  9135 
       
  9136 void CAknFepManager::DimEditMenuModeItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  9137     {
       
  9138     // current item
       
  9139     DimMenuItem(aMenuPane, iMode);
       
  9140 
       
  9141     // dim menu items for Chinese input modes that aren't valid in the current editor
       
  9142     // or the device subvariant
       
  9143     for (TInt mode = KFirstMode; mode <= KLastMode; mode = mode << 1)
       
  9144         {
       
  9145         if (!IsModePermitted(mode))
       
  9146             {
       
  9147             DimMenuItem(aMenuPane, mode);
       
  9148             }
       
  9149         }
       
  9150     
       
  9151     if (IsAbleToLaunchSmiley())
       
  9152         {
       
  9153         TInt index;
       
  9154         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSmiley, index))
       
  9155             {
       
  9156             aMenuPane->SetItemDimmed(EAknCmdEditInsertSmiley, EFalse);
       
  9157             }
       
  9158         }        
       
  9159     }
       
  9160 
       
  9161 void CAknFepManager::DimMenuItem(CAknFepUiInterfaceMenuPane* aMenuPane, TInt aMode)
       
  9162     {
       
  9163     TInt dimmedMenuItem = 0;
       
  9164     switch (aMode)
       
  9165         {
       
  9166         case EPinyin:
       
  9167             dimmedMenuItem = EChinFepCmdModePinyin;
       
  9168             break;
       
  9169         case EZhuyin:
       
  9170             dimmedMenuItem = EChinFepCmdModeZhuyin;
       
  9171             break;
       
  9172         case EStroke:
       
  9173             dimmedMenuItem = EChinFepCmdModeStroke;
       
  9174             break;
       
  9175         case ECangJie:
       
  9176             dimmedMenuItem = EChinFepCmdModeCangJie;
       
  9177             break;
       
  9178         case EZhuyinFind:
       
  9179             dimmedMenuItem = EChinFepCmdModeZhuyinFind;
       
  9180             break;
       
  9181         case EStrokeFind:
       
  9182             dimmedMenuItem = EChinFepCmdModeStrokeFind;
       
  9183             break;
       
  9184         case ELatin:
       
  9185             if ( iLanguageCapabilities.iInputLanguageCode != ELangJapanese)
       
  9186                 {
       
  9187                 // According Katja's info, dim the current case item in the 
       
  9188                 // indicator menu.
       
  9189                 if ( iCaseMan->CurrentCase() == EAknEditorUpperCase )
       
  9190                     {
       
  9191                     dimmedMenuItem = EChinFepCmdModeLatinUpper;
       
  9192                     }
       
  9193                 else if(iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  9194                     {
       
  9195                     dimmedMenuItem = EChinFepCmdModeLatinLower;
       
  9196                     }
       
  9197                 else if(iCaseMan->CurrentCase() == EAknEditorTextCase)
       
  9198                     {
       
  9199                     dimmedMenuItem = EAknCmdEditModeLatinText;
       
  9200                     }
       
  9201                 }
       
  9202             break;
       
  9203         case ENativeNumber:
       
  9204             {
       
  9205             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, ETrue);
       
  9206             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, ETrue);
       
  9207             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, ETrue);
       
  9208             }
       
  9209             break;
       
  9210         default:
       
  9211             break;
       
  9212         }
       
  9213     TInt index;
       
  9214     if (dimmedMenuItem && aMenuPane->MenuItemExists(dimmedMenuItem, index))
       
  9215         {
       
  9216         aMenuPane->SetItemDimmed(dimmedMenuItem, ETrue);
       
  9217         }
       
  9218     }
       
  9219 
       
  9220 void CAknFepManager::LaunchConfirmationNoteL(TInt aResourceId)
       
  9221     {
       
  9222     SetFlag(EFlagForegroundUIComponentVisible);
       
  9223 	iUiInterface->LaunchConfirmationNoteL(aResourceId);
       
  9224     }
       
  9225 
       
  9226 void CAknFepManager::NewCharacterL(const TDesC& aChar)
       
  9227     {
       
  9228     if ( aChar.Length() == 0 )
       
  9229     	{
       
  9230     	return;
       
  9231     	}
       
  9232     TChar ch = aChar[0];
       
  9233 
       
  9234     TBool validNewCandidate = CharIsValidInEditor(ch);
       
  9235     // Check if the character is valid for the editor.
       
  9236     if ( !validNewCandidate )
       
  9237         {
       
  9238         TChar firstNewCandidate = ch;
       
  9239         TBool goneThroughAllCandidates(EFalse);
       
  9240         TPtrC8 sequence = iPtiEngine->CurrentInputSequence();
       
  9241 
       
  9242         if ( sequence.Length() )
       
  9243             {
       
  9244             TPtiKey key = (TPtiKey)sequence[0];
       
  9245                         
       
  9246             TBuf<20> mapData;              
       
  9247             iPtiEngine->MappingDataForKey(key, mapData, iPtiEngine->Case()); 
       
  9248             // If the character was not coming from ptiengine mappings, fail instantly.              
       
  9249             if (mapData.Locate(firstNewCandidate) != KErrNotFound)
       
  9250                 {                
       
  9251                 // If there is an ivalid character in chr-loop, try to jump to next valid one.
       
  9252                 for (TInt jj = 0; jj < mapData.Length(); jj++)
       
  9253                     {
       
  9254                     TPtrC text = iPtiEngine->AppendKeyPress(key);
       
  9255 				    if ( text.Length() == 0 )
       
  9256 				    	{
       
  9257 				    	continue;
       
  9258 				    	}
       
  9259                     ch = text[0];
       
  9260                     goneThroughAllCandidates = (ch == firstNewCandidate);                    
       
  9261                     validNewCandidate = CharIsValidInEditor(ch);
       
  9262                     if (validNewCandidate || goneThroughAllCandidates)
       
  9263                         {
       
  9264                         break;
       
  9265                         }                                        
       
  9266                     }
       
  9267                 }            
       
  9268             }
       
  9269         }
       
  9270     if (!validNewCandidate)
       
  9271         {
       
  9272         // No valid characters at all.
       
  9273         CancelInlineEdit();
       
  9274         return;
       
  9275         }
       
  9276 
       
  9277     if ( (ch == KAknFEPLineFeedSymbol ||
       
  9278           ch == KAknFEPMirroredLineFeedSymbol) &&
       
  9279         (EditorHasFreeSpace() || IsFlagSet(EFlagLastCharacterInEditor)))
       
  9280         {
       
  9281         SetFlag(EFlagLineFeedCharacter);
       
  9282         }
       
  9283     else
       
  9284         {
       
  9285         ClearFlag(EFlagLineFeedCharacter);
       
  9286         }
       
  9287         
       
  9288     if ( (ch == EKeySpace) &&
       
  9289         (EditorHasFreeSpace() || IsFlagSet(EFlagLastCharacterInEditor)))
       
  9290         {
       
  9291         SetFlag(EFlagSpaceCharacter);
       
  9292         }
       
  9293     else
       
  9294         {
       
  9295         ClearFlag(EFlagSpaceCharacter);
       
  9296         }
       
  9297 
       
  9298 
       
  9299     if (iInputCapabilities.SupportsSecretText())
       
  9300         {
       
  9301         if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9302             {
       
  9303             SimulateKeyEventL(EKeyF20); // to delete previous char in secret text editor
       
  9304             }
       
  9305         //we receive an extra key press if we simulate a key that is also a device key
       
  9306         if (ch.IsDigit() || TUint(ch) == EStarKeyUnicodeValue || TUint(ch) == EHashKeyUnicodeValue)
       
  9307             {
       
  9308             SetFlag(EFlagPassNextKey);
       
  9309             }
       
  9310         if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  9311             {
       
  9312             ClearFlag(EFlagPassNextKey);
       
  9313             SimulateKeyEventL(ch + (TChar)KLatinToArabicIndicDigitsDelta ); 
       
  9314             }
       
  9315         else if ( ch.IsDigit() 
       
  9316                && iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )
       
  9317             {
       
  9318             ClearFlag(EFlagPassNextKey);
       
  9319             if(iLanguageCapabilities.iInputLanguageCode == ELangUrdu 
       
  9320             || iLanguageCapabilities.iInputLanguageCode == ELangFarsi)
       
  9321                 {
       
  9322                 SimulateKeyEventL(ch + (TChar)KLatinToEasternArabicIndicDigitsDelta );  
       
  9323                 }
       
  9324             }    
       
  9325         else if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari )
       
  9326             {
       
  9327             ClearFlag(EFlagPassNextKey);
       
  9328             SimulateKeyEventL(ch + (TChar)KLatinToDevanagariDigitsDelta);
       
  9329             }
       
  9330         else
       
  9331             {
       
  9332             SimulateKeyEventL(ch);
       
  9333             }
       
  9334         SetFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction);
       
  9335         }
       
  9336     else if (EditorHasFreeSpace() || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9337         {
       
  9338         TBuf<1> buf;
       
  9339         if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  9340             {
       
  9341             buf.Append( ch + (TChar)KLatinToArabicIndicDigitsDelta );   
       
  9342             }
       
  9343         else if ( ch.IsDigit() 
       
  9344                && iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )
       
  9345             {
       
  9346             if(iLanguageCapabilities.iInputLanguageCode == ELangUrdu 
       
  9347             || iLanguageCapabilities.iInputLanguageCode == ELangFarsi)
       
  9348                 {
       
  9349                 buf.Append( ch + (TChar)KLatinToEasternArabicIndicDigitsDelta );                    
       
  9350                 }
       
  9351             }    
       
  9352         else if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari )
       
  9353             {
       
  9354             buf.Append( ch + (TChar)KLatinToDevanagariDigitsDelta );    
       
  9355             }
       
  9356         else
       
  9357             {
       
  9358             buf.Append( ch );
       
  9359             }
       
  9360 
       
  9361         if (iFepManState == EAknFepStateInitial) //multitapping
       
  9362             {
       
  9363             if (!IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9364                 {
       
  9365                 TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  9366                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9367                 if (iAknEditorFlags & EAknEditorFlagMTAutoOverwrite && iMode == ELatin 
       
  9368                     && !WesternPredictive()
       
  9369                     && iUncommittedText.iCursorPos < edSize 
       
  9370                     && iUncommittedText.Length() == 0)
       
  9371                     {
       
  9372                     // If the cursor is at the beginning or in the middle of the text,
       
  9373                     // existing characters are replaced with new ones in latin multitap input.
       
  9374                     iUncommittedText.iCursorPos++;
       
  9375                     StartInlineEditL(iUncommittedText, buf, ESingleCharacter, EFalse);
       
  9376                     SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9377                     UpdateInlineEditL(buf, ESingleCharacter);
       
  9378                     }
       
  9379                 else
       
  9380                     {
       
  9381                     StartInlineEditL(buf);
       
  9382                     SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9383                     }
       
  9384                 }
       
  9385             else
       
  9386                 {
       
  9387                 UpdateInlineEditL(buf, ESingleCharacter);
       
  9388                 }
       
  9389 
       
  9390             if(!EditorHasFreeSpace())
       
  9391                 {
       
  9392                 SetFlag(EFlagLastCharacterInEditor);
       
  9393                 }
       
  9394             }
       
  9395         else
       
  9396             {
       
  9397             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(buf, ESingleCharacter, 
       
  9398                                                                         ETrue, NULL, *this, *this);
       
  9399             }
       
  9400         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9401         }
       
  9402     }
       
  9403 
       
  9404 void CAknFepManager::NewTextL(const TDesC& aText)
       
  9405     {
       
  9406     ClearFlag(EFlagLineFeedCharacter);
       
  9407     TBool unlimit = EFalse;
       
  9408     TInt freeSpace = EditorFreeSpace(unlimit);
       
  9409 
       
  9410     if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) ||
       
  9411         unlimit || freeSpace > 0 ) //
       
  9412         {
       
  9413         if( unlimit || freeSpace > aText.Length() )
       
  9414             {
       
  9415             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(aText, aText.Length(), ETrue, 
       
  9416                                                                                  NULL, *this, *this);
       
  9417             }
       
  9418         else  
       
  9419             {
       
  9420             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(aText.Left(freeSpace), freeSpace, ETrue, 
       
  9421                                                                                  NULL, *this, *this);
       
  9422             }
       
  9423         
       
  9424         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9425         }
       
  9426     }
       
  9427 
       
  9428 
       
  9429 void CAknFepManager::NewCharacterSequenceL(const TDesC& aText, TIndicInputResponse aResponse)
       
  9430     {
       
  9431     TChar zws((ZERO_WIDTH_SPACE));
       
  9432     TChar virama((TAknFepUiIndicInputManager::Virama(TLanguage(
       
  9433                     iLanguageCapabilities.iInputLanguageCode))));
       
  9434     TBool ret = ETrue;
       
  9435 	TBuf<CAknFepManager::EMaximumFepWordLength> buf;
       
  9436     buf.Zero();
       
  9437     TBool isTextLayoutPresent = (AknFepDocumentNavigation() || TextLayout()) ? ETrue : EFalse;
       
  9438     switch( aResponse )
       
  9439         {
       
  9440         case EIndicInputResponseNone:
       
  9441             {
       
  9442             NewCharacterL(aText);
       
  9443             }
       
  9444             break;
       
  9445         case EIndicInputResponseNumber:
       
  9446             {
       
  9447             NewCharacterL(aText);
       
  9448             CommitInlineEditL();
       
  9449             }
       
  9450             break;
       
  9451         case EIndicInputResponseZWSandCharacter:
       
  9452             {
       
  9453             if (! iInputCapabilities.SupportsSecretText() && isTextLayoutPresent)
       
  9454                 {
       
  9455                 buf.Append(zws);
       
  9456                 NewCharacterL(buf);
       
  9457                 CommitInlineEditL();
       
  9458                 }
       
  9459             NewCharacterL(aText);           
       
  9460             }
       
  9461             break;
       
  9462         case EIndicInputResponseInsertZWS:
       
  9463             {
       
  9464             buf.Append(virama);
       
  9465             if(isTextLayoutPresent)
       
  9466                 buf.Append(zws);
       
  9467             ret = EFalse;           
       
  9468             }
       
  9469             break;
       
  9470         case EIndicInputResponseInsertZWSandLigature:
       
  9471             {
       
  9472             buf.Append(virama);
       
  9473             if(isTextLayoutPresent)
       
  9474                 buf.Append(zws);
       
  9475             if ( iInputCapabilities.SupportsSecretText() )
       
  9476                 {
       
  9477                 buf.Append(aText);  
       
  9478                 }
       
  9479             ret = EFalse;           
       
  9480             }
       
  9481             break;
       
  9482 
       
  9483         case EIndicInputResponseInsertRepha:
       
  9484             {
       
  9485             MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
  9486                 iInputCapabilities.FepAwareTextEditor();
       
  9487 
       
  9488             if( fepAwareTextEditor )
       
  9489                 {
       
  9490                 TInt nextCharPos = 0;
       
  9491                 TCursorSelection curSel;
       
  9492             
       
  9493                 fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
  9494                 
       
  9495                 // Insert Repha before the desired syllable.
       
  9496                 TBool leftFlag = GetNextVisualLeftCharacter( nextCharPos );
       
  9497                 if( leftFlag )
       
  9498                     {
       
  9499                     curSel.iCursorPos = nextCharPos;
       
  9500                     curSel.iAnchorPos = nextCharPos;
       
  9501                     
       
  9502                     fepAwareTextEditor->SetCursorSelectionForFepL( curSel );
       
  9503                                                 
       
  9504                     TAknFepUiIndicInputManager::GetRepha( buf, 
       
  9505                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
  9506 
       
  9507                     ret = EFalse;
       
  9508                     }
       
  9509                 }
       
  9510             break;
       
  9511             }
       
  9512 
       
  9513         case EIndicInputResponseInsertRakar:
       
  9514             {
       
  9515             TAknFepUiIndicInputManager::GetRakar( buf, 
       
  9516                 TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
  9517             ret = EFalse;
       
  9518             }
       
  9519             break;
       
  9520 #ifdef RD_HINDI_PHONETIC_INPUT      
       
  9521     	case EIndicInputResponsePhoneticMultitapText:
       
  9522     		{
       
  9523     		buf.Append(aText);
       
  9524 			ret = EFalse;	
       
  9525     		}
       
  9526     		break;
       
  9527         case EIndicInputResponsePhoneticQwertyText:
       
  9528             {
       
  9529             buf.Append(aText);
       
  9530             ret = EFalse;   
       
  9531             }
       
  9532             break;
       
  9533 #endif          
       
  9534 
       
  9535         case EIndicInputResponseInsertDirectLigature:
       
  9536             {
       
  9537             // In key-0, the new line character preceeds the Ksha.
       
  9538             // First clear the new line flag.
       
  9539             ClearFlag( EFlagLineFeedCharacter );
       
  9540             
       
  9541             buf.Append( aText );
       
  9542             ret = EFalse;
       
  9543             }
       
  9544             break;
       
  9545 
       
  9546         case EIndicInputResponseInsertViramaZWSandDirectLigature:
       
  9547             {
       
  9548             // This case handles the insertion of Virama when star key
       
  9549             // is pressed.
       
  9550 
       
  9551             // In key-0, the new line character preceeds the Ksha.
       
  9552             // First clear the new line flag.
       
  9553             ClearFlag( EFlagLineFeedCharacter );
       
  9554 
       
  9555             buf.Append(virama);
       
  9556             if(isTextLayoutPresent)
       
  9557                 buf.Append(zws);
       
  9558             if ( iInputCapabilities.SupportsSecretText() )
       
  9559                 {
       
  9560                 buf.Append(aText);  
       
  9561                 }
       
  9562             ret = EFalse;
       
  9563             }
       
  9564             break;
       
  9565 
       
  9566         case EIndicInputResponseZWSandDirectLigature:
       
  9567             {
       
  9568             if (! iInputCapabilities.SupportsSecretText() && isTextLayoutPresent)
       
  9569                 {
       
  9570                 buf.Append(zws);
       
  9571                 NewCharacterL(buf);
       
  9572                 CommitInlineEditL();
       
  9573                 }
       
  9574             buf.Zero();
       
  9575             buf.Append( aText );
       
  9576             ret = EFalse;
       
  9577             }
       
  9578             break;
       
  9579 
       
  9580 #ifdef RD_MARATHI
       
  9581 		case EIndicInputResponseInsertEyeLashRa:
       
  9582 			{
       
  9583 			TAknFepUiIndicInputManager::GetEyeLashRa( buf, 
       
  9584 				(TLanguage)iLanguageCapabilities.iInputLanguageCode );
       
  9585 			ret = EFalse;
       
  9586     		}
       
  9587 			break;
       
  9588 
       
  9589 		case EIndicInputResponseInsertChandraA:
       
  9590 			{
       
  9591 			TAknFepUiIndicInputManager::GetChandraA( buf );
       
  9592 			ret = EFalse;
       
  9593 			}
       
  9594 			break;
       
  9595 #endif // RD_MARATHI
       
  9596 
       
  9597         default:
       
  9598             break;
       
  9599         }
       
  9600         
       
  9601     if(ret)
       
  9602         return;
       
  9603     
       
  9604     if ( iInputCapabilities.SupportsSecretText() )
       
  9605         {
       
  9606         if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9607             {
       
  9608             SimulateKeyEventL(EKeyF20); // to delete previous char in secret text editor
       
  9609             }
       
  9610         for( TInt counter=0; counter<buf.Length(); counter++ )
       
  9611             {
       
  9612             if( (buf[counter] != ZERO_WIDTH_SPACE) )
       
  9613                 SimulateKeyEventL(buf[counter]);    
       
  9614             }
       
  9615         SetFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction);
       
  9616         }
       
  9617     else if ( EditorHasFreeSpace() || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9618         {
       
  9619         if ( iFepManState == EAknFepStateInitial ) //multitapping
       
  9620             {
       
  9621             if ( !IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9622                 {
       
  9623                 TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  9624                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9625                 if (iAknEditorFlags & EAknEditorFlagMTAutoOverwrite && iMode == ELatin 
       
  9626                     && !WesternPredictive()
       
  9627                     && iUncommittedText.iCursorPos < edSize 
       
  9628                     && iUncommittedText.Length() == 0)
       
  9629                     {
       
  9630                     // If the cursor is at the beginning or in the middle of the text,
       
  9631                     // existing characters are replaced with new ones in latin multitap input.
       
  9632                     iUncommittedText.iCursorPos++;
       
  9633                     StartInlineEditL(iUncommittedText, buf, ESingleCharacter, EFalse);
       
  9634                     }
       
  9635                 else
       
  9636                     {
       
  9637                     StartInlineEditL();
       
  9638                     }
       
  9639                 SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9640                 }
       
  9641             UpdateInlineEditL(buf, buf.Length());
       
  9642 
       
  9643             if( !EditorHasFreeSpace() )
       
  9644                 {
       
  9645                 SetFlag(EFlagLastCharacterInEditor);
       
  9646                 }
       
  9647             }
       
  9648         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9649 
       
  9650         // Check if text needs to be committed   		
       
  9651         if( ( TAknFepUiIndicInputManager::IsToCommitCharSeq( aResponse ) ) )
       
  9652             {
       
  9653             CommitInlineEditL();    
       
  9654             }
       
  9655         if( aResponse == EIndicInputResponseInsertZWSandLigature )
       
  9656             {
       
  9657             NewCharacterL(aText);   
       
  9658             }    
       
  9659         else if( aResponse == EIndicInputResponseInsertViramaZWSandDirectLigature )
       
  9660             {
       
  9661             // Doing this here because we first commit the virama 
       
  9662             // and ZWS and keep the ligature in the inline buffer.
       
  9663             NewLigatureL( aText );
       
  9664             }
       
  9665         }
       
  9666     }
       
  9667 
       
  9668 void CAknFepManager::CommitInlineEditL()
       
  9669     {   
       
  9670     if ( !IsFlagSet( CAknFepManager::EFlagInsideInlineEditingTransaction ) )
       
  9671         {
       
  9672         return;
       
  9673         }
       
  9674 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  9675     // Before commit inline, check and close 
       
  9676     // tooltip on FSQ first.
       
  9677     SendEventsToPluginManL( EPluginHideTooltip );
       
  9678 
       
  9679     // Predictive QWERTY (XT9) changes ---->
       
  9680     // Exact word popup is hidden when the inline editor is closed
       
  9681     iExactWordPopupContent->HidePopUp();
       
  9682     // Predictive QWERTY (XT9) changes <----
       
  9683 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  9684     if (iInputCapabilities.FepAwareTextEditor())
       
  9685 			{
       
  9686 	    if  (IsFlagSet(EFlagLineFeedCharacter))
       
  9687 	        {
       
  9688 	        if (iInputCapabilities.SupportsSecretText())
       
  9689 	            {
       
  9690 	            SimulateKeyEventL(EKeyF20); // backspace to delete previous char in secret text editor
       
  9691 	            SimulateKeyEventL(EKeyEnter);
       
  9692 	            SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9693 	            }
       
  9694 	        else
       
  9695 	            {
       
  9696 	            __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
  9697 	                           AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  9698 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);
       
  9699 	            iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  9700 	            
       
  9701 	            // Multitapping enter event is not posted for find pane.
       
  9702 	            // It would never accept it anyway but the event causes problems in gallery's find.
       
  9703 	            // Allow real enter from qwerty keyboard though.
       
  9704 	            if (!(iAknEditorFlags & EAknEditorFlagFindPane) || iQwertyInputMode)
       
  9705 	                {                
       
  9706 	                SimulateKeyEventL(EKeyEnter);
       
  9707 	                SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9708 	                }            
       
  9709 	            }
       
  9710 	        }
       
  9711 	    else if (IsFlagSet(EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter))
       
  9712 	        {
       
  9713 	        TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
  9714 	
       
  9715 	        if (IsFlagSet(EFlagSpaceCharacter))
       
  9716 	            {
       
  9717 	            charAsDesc[0] = TText(0x0020);      // 0x0020 is space
       
  9718 	            }
       
  9719 	        else
       
  9720 	            {
       
  9721 	            charAsDesc[0] = TText(0x3000);      // 0x3000 is full-width space
       
  9722 	            }
       
  9723 	
       
  9724 	        if (iInputCapabilities.SupportsSecretText())
       
  9725 	            {
       
  9726 	            SimulateKeyEventL(EKeyF20); // backspace to delete previous char in secret text editor
       
  9727 	            SimulateKeyEventL(charAsDesc[0]);
       
  9728 	            SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9729 	            }
       
  9730 	        else
       
  9731 	            {
       
  9732 	            iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(charAsDesc, 1);
       
  9733 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);
       
  9734 	            CCoeEnv* coeEnv = CCoeEnv::Static();
       
  9735 	            iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
  9736 	            iCaseMan->UpdateCase(ENullNaviEvent);
       
  9737 	            if (!EditorHasFreeSpace())
       
  9738 	                {
       
  9739 	                SetFlag(EFlagEditorFull);
       
  9740 	                }
       
  9741 	            else
       
  9742 	            	{
       
  9743 	            	ClearFlag(EFlagEditorFull);
       
  9744 	            	}
       
  9745 	            }
       
  9746 	        }
       
  9747 	    else if (IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
  9748 	         && !iInputCapabilities.SupportsSecretText())
       
  9749 	        {
       
  9750 	        // Chinese languages seem not to support this
       
  9751 	        if ( !IsChineseInputLanguage() &&
       
  9752 	            (iUncommittedText.Length() == 0 || 
       
  9753 	                    (
       
  9754 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
  9755 	                    !IsAutoCompleteOn() &&
       
  9756 	#endif //RD_INTELLIGENT_TEXT_INPUT                    
       
  9757 	                    !EditorSupportsNeutralProtection()
       
  9758 	                    ) 
       
  9759 	            )
       
  9760 	           )
       
  9761 	                    
       
  9762 	            { // empty insertions need no resolution.
       
  9763 	            /*Hindi*/
       
  9764 	            if( (TAknFepUiIndicInputManager :: IsIndicLangauge(
       
  9765 	                      TLanguage(iLanguageCapabilities.iInputLanguageCode))) 
       
  9766 	#ifdef RD_HINDI_PHONETIC_INPUT
       
  9767 	                || ( TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(
       
  9768 	                      TLanguage(iLanguageCapabilities.iInputLanguageCode)) )
       
  9769 	#endif
       
  9770 	            )
       
  9771 	                {
       
  9772 	                // NOTE! Need to get cursor visibility information from some where.
       
  9773 	                CommitInlineEditWithoutResolutionL( *(iInputCapabilities.FepAwareTextEditor()), 
       
  9774 	                                                    ETrue, EFalse); 
       
  9775 	                }
       
  9776 	            else
       
  9777 	                {
       
  9778 	                // NOTE! Need to get cursor visibility information from some where.
       
  9779 	                CommitInlineEditWithoutResolutionL( *(iInputCapabilities.FepAwareTextEditor()), 
       
  9780 	                                                    ETrue);
       
  9781 	                }
       
  9782 	            }
       
  9783 	        else
       
  9784 	            {
       
  9785 	
       
  9786 	            //note secret text editors do not use the MCoeFepAwareTextEditor interface,
       
  9787 	            //we only need to clear the flags to 'commit' a character
       
  9788 	
       
  9789 	            __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
  9790 	                           AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  9791 	            CCoeEnv* coeEnv = CCoeEnv::Static();
       
  9792 	
       
  9793 	            TBool showCursor = ETrue;
       
  9794 	            if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) ||
       
  9795 	                IsCcpuFlagSet(ECcpuStateLosingFocus))
       
  9796 	                {
       
  9797 	                showCursor = EFalse;
       
  9798 	                }
       
  9799                 else
       
  9800                     {
       
  9801                     if(IsKoreanInputLanguage( ) && IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
  9802                         {
       
  9803                         showCursor = EFalse;
       
  9804                         }
       
  9805                     }
       
  9806 
       
  9807 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(showCursor);
       
  9808 	            ClearFlag(EFlagInsideInlineEditingTransaction);
       
  9809 	            iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
  9810 	
       
  9811 	            // Arabic & Hebrew required functionality added ---->
       
  9812 	            if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction)) // Condition added for AknFep.
       
  9813 	                {
       
  9814 	                // 3 * as each original character can potentially take 2 markers
       
  9815 	                HBufC* decoratedTextBuf = HBufC::NewLC(KMaxInlineEditSize + 2); // +2 to accommodate previous and next charcaters
       
  9816 	                TPtr decoratedText = decoratedTextBuf->Des();
       
  9817 	                // Resolve in a slightly wider range than the new text. Attempt to expand 1 character in each direction
       
  9818 	                TCursorSelection resolveSpan(iUncommittedText.HigherPos(), 
       
  9819 	                                             iUncommittedText.LowerPos());
       
  9820 	                TInt decCursor = 0;
       
  9821 	
       
  9822 	                // Gets the CPlainText object from the focused editor if it exists.
       
  9823 	                CPlainText* plainText = PlainText();
       
  9824 	                TBool containsTextField = EFalse;
       
  9825 	                if (resolveSpan.iAnchorPos > 0)
       
  9826 	                    {
       
  9827 	                    if (plainText)
       
  9828 	                        {
       
  9829 	                        // Check if surrounding document position contains text field.
       
  9830 	                        containsTextField = plainText->FindFields(resolveSpan.iAnchorPos - 1);
       
  9831 	                        }
       
  9832 	                    TBuf<ESingleCharacter> chDes;
       
  9833 	                    iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, 
       
  9834 	                                              resolveSpan.iAnchorPos - 1, ESingleCharacter);
       
  9835 	                    if ( chDes.Length() != 0 && chDes[0] != CEditableText::EPictureCharacter && !containsTextField)
       
  9836 	                        {
       
  9837 	                        // Resolve span is not extended if surrounding character is picture character or it
       
  9838 	                        // contains text field. Text field data would be lost when FEP replaces existing editor
       
  9839 	                        // content with new text buffer content that does not have text field data.
       
  9840 	                        // ResolveDecoratedText() call does not handle these special cases which can has some 
       
  9841 	                        // effects to Arabic & Hebrew text rendering.
       
  9842 	                        resolveSpan.iAnchorPos--;
       
  9843 	                        }
       
  9844 	                    }
       
  9845 	                if (resolveSpan.iCursorPos < 
       
  9846 	                    iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
  9847 	                    {
       
  9848 	                    containsTextField = EFalse;
       
  9849 	                    if (plainText)
       
  9850 	                        {
       
  9851 	                        // Check if surrounding document position contains text fields.
       
  9852 	                        containsTextField = plainText->FindFields(resolveSpan.iCursorPos);
       
  9853 	                        }
       
  9854 	                    TBuf<ESingleCharacter> chDes;
       
  9855 	                    iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, 
       
  9856 	                                                  resolveSpan.iCursorPos, ESingleCharacter);
       
  9857 	                    if ( chDes.Length() != 0 && chDes[0] != CEditableText::EPictureCharacter && !containsTextField)
       
  9858 	                        {
       
  9859 	                        // Resolve span is not extended if surrounding character is picture character or it
       
  9860 	                        // contains text field. Text field data would be lost when FEP replaces existing editor
       
  9861 	                        // content with new text buffer content that does not have text field data.
       
  9862 	                        // ResolveDecoratedText() call does not handle these special cases which can has some 
       
  9863 	                        // effect to Arabic & Hebrew text rendering.
       
  9864 	                        resolveSpan.iCursorPos++;
       
  9865 	                        decCursor++;
       
  9866 	                        }
       
  9867 	                    }
       
  9868 	
       
  9869 	                // resolveSpan has been widened. Now go get the text for that span.
       
  9870 	                iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(decoratedText, 
       
  9871 	                                                 resolveSpan.iAnchorPos, resolveSpan.Length());
       
  9872 	
       
  9873 	                if ( decoratedText.Length() != resolveSpan.Length() )
       
  9874 	                    {
       
  9875 	                    // This assert checks is we have failed to retrieve enough text.  Should not happen
       
  9876 	                    // __ASSERT_DEBUG( decoratedText.Length() == resolveSpan.Length(),  Panic(EEikPanicT9CharPosOutOfRange) );
       
  9877 	                    // Abondon the resolution.
       
  9878 	
       
  9879 	                    iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL( ETrue );
       
  9880 	                    }
       
  9881 	                else
       
  9882 	                    {
       
  9883 	                    TInt lowerOffset = iUncommittedText.LowerPos() - resolveSpan.LowerPos();
       
  9884 	
       
  9885 	                    TBool needsResolving = iInlineTextDecorator->ResolveDecoratedText(decoratedText,
       
  9886 	                        TCursorSelection(lowerOffset, lowerOffset + iUncommittedText.Length()));
       
  9887 	
       
  9888 	                    if ( needsResolving )
       
  9889 	                        {                      
       
  9890 	                        TBool setToTrue=EFalse;
       
  9891 	                        iInputCapabilities.FepAwareTextEditor()->Extension1()->StartFepInlineEditL(
       
  9892 	                            setToTrue,
       
  9893 	                            resolveSpan,
       
  9894 	                            decoratedText,
       
  9895 	                            decoratedText.Length() - decCursor,
       
  9896 	                            EFalse,
       
  9897 	                            0, // MFormCustomDrawer*
       
  9898 	                            *this,
       
  9899 	                            *this);
       
  9900 	
       
  9901 	                        iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL( ETrue );
       
  9902 	                        if (IsFeatureSupportedJapanese())
       
  9903 	                            {
       
  9904 	                            // need to call clear buffer of PtiEngine for Japanese varint
       
  9905 	                            // before calling second CommitFepInlineEditL().
       
  9906 	                            // because the committed string is set as reading string twice
       
  9907 	                            iPtiEngine->ClearCurrentWord();
       
  9908 	                            }
       
  9909 	                        iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
  9910 	                        }
       
  9911 	                    else
       
  9912 	                        {
       
  9913 	                        // Go directly via CTextView because the normal way via the FepAwareEditor can only be called
       
  9914 	                        // during an inline edit.
       
  9915 	                        // Line cursor is made invisible here.  There is no line cursor in S60 LAF, even though there is
       
  9916 	                        // an Edwin flag which govern this.  See CEikEdwin::SetCursorVisibilityL(TBool)
       
  9917 	                        // Cursor is not set if this CommitInlineEditL call was prompted when losing focus.
       
  9918 	                        MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
  9919 	                        if ( (docNavi || TextView()) && !IsCcpuFlagSet(ECcpuStateLosingFocus) )
       
  9920 	                        	{
       
  9921 	                        	if (docNavi)
       
  9922 	                        		{
       
  9923 		                            docNavi->SetCursorVisibilityL( TCursor::EFCursorInvisible, 
       
  9924 	                                                             TCursor::EFCursorFlashing );
       
  9925 	                        		}
       
  9926 	                        	else 
       
  9927 	                        		{
       
  9928 		                            TextView()->SetCursorVisibilityL( TCursor::EFCursorInvisible, 
       
  9929 	                                                                TCursor::EFCursorFlashing );
       
  9930 	                        		}
       
  9931 	                        	}
       
  9932 	                        }
       
  9933 	                    }
       
  9934 	                // iMatchState=EWordMatchFirst;
       
  9935 	
       
  9936 	                CleanupStack::PopAndDestroy(); // decoratedTextBuf
       
  9937 	                }
       
  9938 	            if (iInputCapabilities.FepAwareTextEditor())
       
  9939 	                {
       
  9940 	                iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);   
       
  9941 	                }
       
  9942 	            
       
  9943 	            iCaseMan->UpdateCase(ENullNaviEvent);
       
  9944 	            // <---- Arabic & Hebrew required functionality added
       
  9945 	            if (!EditorHasFreeSpace())
       
  9946 	                {
       
  9947 	                SetFlag(EFlagEditorFull);
       
  9948 	                }
       
  9949 	            else
       
  9950 	            	{
       
  9951 	            	ClearFlag(EFlagEditorFull);
       
  9952 	            	}
       
  9953 	            }
       
  9954 	        }
       
  9955 	    else if (IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
  9956 	          && iInputCapabilities.SupportsSecretText())
       
  9957 	        {
       
  9958 	        CCoeEnv* coeEnv = CCoeEnv::Static();
       
  9959 	        iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
  9960 	        iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9961 	        
       
  9962 	        if (iQwertyInputMode)
       
  9963 	            {
       
  9964 	            // Case may need to updated automatically in case of qwerty secret text editor
       
  9965 	            // beause of the sticky shift feature.
       
  9966 	            if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  9967 	                {
       
  9968 	                SetCase(ELowerCase);            
       
  9969 	                }
       
  9970 	            else
       
  9971 	                {
       
  9972 	                SetCase(EUpperCase);                        
       
  9973 	                }               
       
  9974 	            UpdateIndicators();         
       
  9975 	            }
       
  9976 	        }
       
  9977 			}
       
  9978     
       
  9979 //    SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncUpdatedText );
       
  9980       
       
  9981     ClearFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction |
       
  9982         EFlagLineFeedCharacter | EFlagLastCharacterInEditor | EFlagSpaceCharacter |
       
  9983         EFlagFullWidthSpaceCharacter);
       
  9984         
       
  9985     // No-edit_key devices: Inline editing ending, allow edit-menu again.    
       
  9986     ClearCcpuFlag(ECcpuStateIgnoreStarUp | ECcpuStateNewPredictiveWord);        
       
  9987 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  9988     iUncommittedText.iCursorPos=0;
       
  9989     iUncommittedText.iAnchorPos=0;
       
  9990 #endif 
       
  9991     if (!iInputCapabilities.FepAwareTextEditor())
       
  9992         {
       
  9993         // In case while updating the inline edit, 3rd party app removes the focus out of editor before the transaction
       
  9994         // completes, we return with an error.
       
  9995         User::Leave(KErrCorrupt);
       
  9996         }
       
  9997 
       
  9998     }
       
  9999 
       
 10000 void CAknFepManager::CommitInlineEditL(const TDesC& aText, TInt aUncommitedTextChange)
       
 10001     {
       
 10002     if (iMode == EHiraganaKanji)
       
 10003         {
       
 10004         // When there is not enough editing space to enter the selected candidate,
       
 10005         // the error tone is played.
       
 10006         if ((iFreeSpaceOfEditor > 0) && (iFreeSpaceOfEditor < aText.Length()))
       
 10007             {
       
 10008             PlaySound(EAvkonSIDErrorTone);
       
 10009             }
       
 10010         }
       
 10011 
       
 10012     //maxLength of 0 means the editor has no limit
       
 10013     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10014     if ( maxEdSize != 0 && iFreeSpaceOfEditor < aText.Length())
       
 10015         {
       
 10016         TPtrC charbuf = aText.Left(iFreeSpaceOfEditor);
       
 10017         TInt uncommitedTextChange = charbuf.Length();
       
 10018         UpdateInlineEditL(charbuf, uncommitedTextChange);
       
 10019         }
       
 10020     else
       
 10021         {
       
 10022         UpdateInlineEditL(aText, aUncommitedTextChange);
       
 10023         }
       
 10024 
       
 10025     ClearFlag(EFlagInsideMultitapInlineEditingTransaction);
       
 10026     CommitInlineEditL();
       
 10027     }
       
 10028 
       
 10029 void CAknFepManager::CancelInlineEdit()
       
 10030     {
       
 10031     if( !EditorState()->CurrentInlineEditSpan().Length() )
       
 10032     	{
       
 10033     	ClearFlag(EFlagInsideInlineEditingTransaction);
       
 10034     	if(IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 10035     		{
       
 10036     		ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 10037     		}
       
 10038     	}
       
 10039     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 10040         {
       
 10041         TRAP_IGNORE(TryRemoveNoMatchesIndicatorL());
       
 10042 
       
 10043         if (iInputCapabilities.SupportsSecretText())
       
 10044             {
       
 10045             TRAP_IGNORE(SimulateKeyEventL(EKeyF20)); // backspace to delete previous char in secret text editor
       
 10046             }
       
 10047         else if (IsFeatureSupportedJapanese()
       
 10048               && iFepManState == EAknFepStateUIActive)
       
 10049             {
       
 10050             FepUI()->CloseUI();
       
 10051             FepUI()->ExpireMultitapTimer();
       
 10052             iPtiEngine->ClearCurrentWord();
       
 10053             SyncStates(EAknFepStateInitial);
       
 10054             }
       
 10055         }
       
 10056 
       
 10057     iUncommittedText.iCursorPos=0;
       
 10058     
       
 10059     iUncommittedText.iAnchorPos=0;
       
 10060     
       
 10061     iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
 10062     ClearFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction 
       
 10063               | EFlagLineFeedCharacter | EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 10064     ClearCcpuFlag(ECcpuStateNewPredictiveWord);    
       
 10065     }
       
 10066 
       
 10067 void CAknFepManager::GetScreenCoordinatesL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, 
       
 10068                                            TInt& aAscent, TInt aDocumentOffset)
       
 10069     {
       
 10070     TCursorSelection cursorSelection;
       
 10071     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection);
       
 10072     TInt documentPosition = cursorSelection.LowerPos()  - aDocumentOffset;
       
 10073     if (documentPosition < 0)
       
 10074         documentPosition = 0;
       
 10075     iInputCapabilities.FepAwareTextEditor()->GetScreenCoordinatesForFepL(aLeftSideOfBaseLine, 
       
 10076                                                           aHeight, aAscent, documentPosition);
       
 10077     }
       
 10078 
       
 10079 void CAknFepManager::GetScreenCoordinatesL(TPoint& aLeftSideOfBaseLine, 
       
 10080                                            TInt& aHeight, TInt& aAscent)
       
 10081     {
       
 10082     TCursorSelection cursorSelection;
       
 10083     MCoeFepAwareTextEditor* fepAwareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 10084 
       
 10085     fepAwareTextEditor->GetCursorSelectionForFep(cursorSelection);
       
 10086     fepAwareTextEditor->GetScreenCoordinatesForFepL(aLeftSideOfBaseLine, aHeight, aAscent, 
       
 10087                                                     cursorSelection.LowerPos());
       
 10088     }
       
 10089 
       
 10090 TBool CAknFepManager::EditorHasFreeSpace( TInt aRequiredNumberOfCharacter ) const
       
 10091     {
       
 10092     TBool unlimit = EFalse;
       
 10093     TInt freeSpace = 0;
       
 10094 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10095 	if(WesternPredictive())
       
 10096 	    {
       
 10097 	    freeSpace = EditorFreeSpaceForAutoWordCompletion(unlimit);	
       
 10098 	    }
       
 10099 	else
       
 10100 		{
       
 10101 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10102     	freeSpace = EditorFreeSpace(unlimit);			
       
 10103 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10104 		}
       
 10105 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10106     if( unlimit || freeSpace > aRequiredNumberOfCharacter )
       
 10107         {
       
 10108         return ETrue;
       
 10109         }
       
 10110     return EFalse;
       
 10111     }
       
 10112 
       
 10113 TBool CAknFepManager::IsEditorHasFreeSpace() const
       
 10114     {
       
 10115     TBool unlimit = EFalse;
       
 10116     TInt freeSpace = 0;
       
 10117 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10118 	if(WesternPredictive())
       
 10119 	    {
       
 10120 	    freeSpace = EditorFreeSpaceForAutoWordCompletion(unlimit);	
       
 10121 	    }
       
 10122 	else
       
 10123 		{
       
 10124 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10125     	freeSpace = EditorFreeSpace(unlimit);			
       
 10126 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10127 		}
       
 10128 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10129     if( unlimit || freeSpace > 0 )
       
 10130         {
       
 10131         return ETrue;
       
 10132         }
       
 10133     return EFalse;
       
 10134     }
       
 10135     
       
 10136 TInt CAknFepManager::EditorFreeSpace(TBool& aUnlimit, 
       
 10137     TBool isToCountUncommittedTextLength /*= EFalse */) const
       
 10138     {
       
 10139     aUnlimit = EFalse;
       
 10140 
       
 10141     if (!iInputCapabilities.FepAwareTextEditor())
       
 10142         {
       
 10143         //no handle to MCoeFepAwareTextEditor in non Edwin derived editors
       
 10144         return 0;
       
 10145         }
       
 10146 
       
 10147     //maxLength of 0 means the editor has no limit
       
 10148     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10149     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10150     TCursorSelection currentSelection;
       
 10151     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelection);
       
 10152 
       
 10153     aUnlimit = (maxEdSize == 0 || ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) &&
       
 10154                                    (currentSelection.iCursorPos >= 0 && 
       
 10155                                     currentSelection.iCursorPos < maxEdSize) ));
       
 10156     if(aUnlimit)
       
 10157         {
       
 10158         return 0;
       
 10159         }
       
 10160     else
       
 10161         {
       
 10162         if( isToCountUncommittedTextLength )
       
 10163             {
       
 10164             return ( maxEdSize - edSize + 
       
 10165                 currentSelection.Length() + UncommittedText().Length() );
       
 10166             }
       
 10167         return (maxEdSize - edSize + currentSelection.Length());
       
 10168         }
       
 10169     }
       
 10170 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10171 TInt CAknFepManager::EditorFreeSpaceForAutoWordCompletion(TBool& aUnlimit, 
       
 10172     TBool /* isToCountUncommittedTextLength = EFalse*/ ) const
       
 10173     {
       
 10174     aUnlimit = EFalse;
       
 10175 
       
 10176     if (!iInputCapabilities.FepAwareTextEditor())
       
 10177         {
       
 10178         //no handle to MCoeFepAwareTextEditor in non Edwin derived editors
       
 10179         return 0;
       
 10180         }
       
 10181 
       
 10182     //maxLength of 0 means the editor has no limit
       
 10183     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10184     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10185     TInt keySequenceLength = iPtiEngine->CurrentInputSequence().Length();
       
 10186     TCursorSelection currentSelectionOrUncommitted;    
       
 10187 	iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelectionOrUncommitted);
       
 10188 
       
 10189     aUnlimit = (maxEdSize == 0 || ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) &&
       
 10190                                    (currentSelectionOrUncommitted.iCursorPos >= 0 && 
       
 10191                                     currentSelectionOrUncommitted.iCursorPos < maxEdSize) ));
       
 10192     if(aUnlimit)
       
 10193         {
       
 10194         return 0;
       
 10195         }
       
 10196     else
       
 10197         {
       
 10198 
       
 10199         if ( !iQwertyInputMode )
       
 10200             {
       
 10201             return ( maxEdSize - edSize + currentSelectionOrUncommitted.Length() );
       
 10202             }
       
 10203         else
       
 10204             {
       
 10205             // In the predictive QWERTY mode, the keySequenceLength doesn't necessarily have anything
       
 10206             // to do with the amount of characters on screen. At least entering accented characters with
       
 10207             // Chr-multitapping will increase the key sequence length although number of characters 
       
 10208             // doesn't change (this is either bug or feature of ZiCore). Ask the auto-completion
       
 10209             // length directly from PtiEngine instead of trying to calculate it on our own.
       
 10210             TInt tailLength = 0;
       
 10211             TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 10212             if( tailLength < 0 )
       
 10213              {
       
 10214              tailLength = 0;
       
 10215              }
       
 10216             return (maxEdSize - edSize + currentSelectionOrUncommitted.Length() + tailLength);
       
 10217             }
       
 10218         }
       
 10219     }
       
 10220 #endif
       
 10221 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 10222 #ifdef RD_INTELLIGENT_TEXT_INPUT  
       
 10223 
       
 10224 TInt CAknFepManager::DocumentLength() const
       
 10225     {
       
 10226     TInt ret = 0;
       
 10227     if ( iInputCapabilities.FepAwareTextEditor() )
       
 10228         {
       
 10229         ret = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10230         }
       
 10231     return ret;
       
 10232     }
       
 10233     
       
 10234 TBool CAknFepManager::KeyEventWillReplaceCharacter( const TKeyEvent& aKeyEvent )
       
 10235     {
       
 10236     // The function is currently used only in QWERTY mode. It might not work correctly
       
 10237     // with ITU-T input.
       
 10238     TBool ret = EFalse;
       
 10239     if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
 10240         {
       
 10241         // Multitapping
       
 10242         ret = ETrue;
       
 10243         }
       
 10244     else if ( aKeyEvent.iRepeats &&
       
 10245               LongPressNumberEntryOnQwerty() &&
       
 10246               FnKeyState() == CAknFepFnKeyManager::EFnKeyNone &&
       
 10247               KeyMapsDifferentCharacterWithFn( (TPtiKey)aKeyEvent.iScanCode ) )
       
 10248         {
       
 10249         // QWERTY key long press producing another charcter
       
 10250         ret = ETrue;
       
 10251         }
       
 10252     return ret;    
       
 10253     }
       
 10254 #endif
       
 10255 #endif
       
 10256 TChar CAknFepManager::CurrentDecimalSeparator() const
       
 10257     {
       
 10258     TLocale tLoc;
       
 10259     return tLoc.DecimalSeparator();
       
 10260     }
       
 10261 
       
 10262 void CAknFepManager::ConfigureFEPFromEditorStateL()
       
 10263     {
       
 10264     User::LeaveIfError(SyncStates(EAknFepStateInitial));
       
 10265 
       
 10266     CAknEdwinState* editorState = EditorState();
       
 10267     TInt editorMode = editorState->CurrentInputMode();
       
 10268     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 10269     TBool latinCaseSet = EFalse;
       
 10270     iPermittedInputModes = editorState->PermittedInputModes();
       
 10271     TInt defaultInputMode = editorState->DefaultInputMode();
       
 10272     if(iAknEditorFlags != editorState->Flags())
       
 10273         {
       
 10274         iAknEditorFlags = editorState->Flags();
       
 10275         UpdateLocalDigitMode();
       
 10276         }
       
 10277     iAknEditorNumericKeymap = editorState->NumericKeymap();
       
 10278 
       
 10279     TLanguage localLanguage = ELangTest;
       
 10280     if (GetLocalLanguage( localLanguage ) )
       
 10281         {
       
 10282         iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
 10283         if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
 10284             {
       
 10285             ChangeInputLanguageL(localLanguage);
       
 10286             }
       
 10287         }
       
 10288     else if (iLanguageCapabilities.iLocalInputLanguageInUse)
       
 10289         {
       
 10290         ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
 10291         iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
 10292         ClearFlag(EFlagNewSharedDataInputMode);
       
 10293 		}
       
 10294 
       
 10295     if (IsFlagSet(EFlagNewSharedDataInputLanguage) )
       
 10296         {
       
 10297         //Global mode or input language has been changed in general settings
       
 10298         if ( !iLanguageCapabilities.iLocalInputLanguageInUse)
       
 10299             {
       
 10300             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
 10301             }
       
 10302         ClearFlag(EFlagNewSharedDataInputLanguage);
       
 10303         }
       
 10304 
       
 10305     if (IsFeatureSupportedJapanese())
       
 10306         {
       
 10307         // set Japanese predicitve ON/OFF
       
 10308         if (iAknEditorFlags & EAknEditorFlagNoT9)
       
 10309             {
       
 10310             iJapanesePredictive = EFalse;
       
 10311             }
       
 10312         else
       
 10313             {
       
 10314             // Is it supported Japanese predictive input
       
 10315             if (HasJapanesePredictionInputMode())
       
 10316                 {
       
 10317                 iJapanesePredictive = iSharedDataInterface->PredictiveTextJapaneseOn();
       
 10318                 }
       
 10319             else
       
 10320                 {
       
 10321                 // if Predictive Japanese input isn't supported in PtiEngine, set to OFF.
       
 10322                 iJapanesePredictive = EFalse;
       
 10323                 iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 10324                 }
       
 10325             }
       
 10326 
       
 10327         // In Japanese variant, EAknEditorTextInputMode of allow input mode
       
 10328         // means all input mode.
       
 10329         if (iPermittedInputModes & EAknEditorTextInputMode)
       
 10330             {
       
 10331             iPermittedInputModes |= (EAknEditorKatakanaInputMode |
       
 10332                                     EAknEditorHalfWidthTextInputMode |
       
 10333                                     EAknEditorFullWidthTextInputMode |
       
 10334                                     EAknEditorFullWidthNumericInputMode |
       
 10335                                     EAknEditorFullWidthKatakanaInputMode |
       
 10336                                     EAknEditorHiraganaKanjiInputMode |
       
 10337                                     EAknEditorHiraganaInputMode);
       
 10338             }
       
 10339 
       
 10340         if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
 10341             {
       
 10342             if (iPermittedInputModes == EAknEditorNumericInputMode)
       
 10343                 {
       
 10344                 iPermittedInputModes = EAknEditorNumericInputMode;
       
 10345                 }
       
 10346             else if (iPermittedInputModes & EAknEditorNumericInputMode)
       
 10347                 {
       
 10348                 iPermittedInputModes = (EAknEditorHalfWidthTextInputMode 
       
 10349                                       | EAknEditorNumericInputMode);
       
 10350                 }
       
 10351             else
       
 10352                 {
       
 10353                 iPermittedInputModes = EAknEditorHalfWidthTextInputMode;
       
 10354                 }
       
 10355             }
       
 10356 
       
 10357         if (editorMode)
       
 10358             {
       
 10359             editorMode = ConfigureFepModeFromEditorMode(editorMode);
       
 10360             }
       
 10361         else // for new editors
       
 10362             {
       
 10363             iCharWidth = EHalfWidthChar;
       
 10364             sharedDataMode = EHiraganaKanji;
       
 10365             // First input mode is changed to Latin from Hiragana/Kanji
       
 10366             // if display language is English.
       
 10367             TInt dispLang = iSharedDataInterface->DisplayLanguage();
       
 10368             // ELangTest means Automatic as display language in GS
       
 10369             if (dispLang == ELangTest)
       
 10370                 {
       
 10371                 // UiLanguage isn't Japanese, Latin is set.
       
 10372                 if (iUiLanguage != ELangJapanese)
       
 10373                     {
       
 10374                     sharedDataMode = ELatin;
       
 10375                     }
       
 10376                 }
       
 10377             else if (dispLang != ELangJapanese)
       
 10378                 {
       
 10379                 // Display language isn't Japanese, Latin is set.
       
 10380                 sharedDataMode = ELatin;
       
 10381                 }
       
 10382 
       
 10383             if (!(iPermittedInputModes & EAknEditorHiraganaKanjiInputMode))
       
 10384                 {
       
 10385                 if (IsOnlyFullWidthCharacterPermitted())
       
 10386                     {
       
 10387                     iCharWidth = EFullWidthChar;
       
 10388                     }
       
 10389                 else if (IsOnlyHalfWidthCharacterPermitted())
       
 10390                     {
       
 10391                     iCharWidth = EHalfWidthChar;
       
 10392                     }
       
 10393 
       
 10394                 if (iPermittedInputModes & (EAknEditorKatakanaInputMode |
       
 10395                                         EAknEditorFullWidthKatakanaInputMode))
       
 10396                     {
       
 10397                     // In case setting Latin as above, Latin is used preferentially.
       
 10398                     if (sharedDataMode == ELatin
       
 10399                      && (iPermittedInputModes & 
       
 10400                            (EAknEditorHalfWidthTextInputMode | EAknEditorFullWidthTextInputMode)))
       
 10401                         {
       
 10402                         sharedDataMode = ELatin;
       
 10403                         }
       
 10404                     else
       
 10405                         {
       
 10406                         sharedDataMode = EKatakana;
       
 10407                         }
       
 10408                     }
       
 10409                 else if (iPermittedInputModes & (EAknEditorHalfWidthTextInputMode |
       
 10410                                              EAknEditorFullWidthTextInputMode))
       
 10411                     {
       
 10412                     sharedDataMode = ELatin;
       
 10413                     }
       
 10414                 else if (iPermittedInputModes & (EAknEditorNumericInputMode |
       
 10415                                                  EAknEditorFullWidthNumericInputMode))
       
 10416                     {
       
 10417                     sharedDataMode = ENumber;
       
 10418                     }
       
 10419                 // First input mode is changed to latin from katakana
       
 10420                 // if display language is English.
       
 10421                 if (!(dispLang == ELangTest || dispLang == ELangJapanese))
       
 10422                     {
       
 10423                     if ((iPermittedInputModes &  EAknEditorKatakanaInputMode) &&
       
 10424                         (iPermittedInputModes & EAknEditorHalfWidthTextInputMode))
       
 10425                         {
       
 10426                         sharedDataMode = ELatin;
       
 10427                         }
       
 10428 
       
 10429                     if ((iPermittedInputModes &  EAknEditorKatakanaInputMode) &&
       
 10430                         (iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 10431                         {
       
 10432                         sharedDataMode = ELatin;
       
 10433                         }
       
 10434                     }
       
 10435                 }
       
 10436             }
       
 10437         }
       
 10438     else // for other variants (western or chinese)
       
 10439         {
       
 10440         if (!(iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorNumericInputMode 
       
 10441             | EAknEditorSecretAlphaInputMode)))
       
 10442             {
       
 10443             // Any latin input mode is not permitted by the editor.
       
 10444             // For compatibility permitted japanese input modes are checked and
       
 10445             // corresponding latin input modes are allowed.
       
 10446             if ( iPermittedInputModes & (EAknEditorKatakanaInputMode |
       
 10447                                     EAknEditorHalfWidthTextInputMode |
       
 10448                                     EAknEditorFullWidthTextInputMode |
       
 10449                                     EAknEditorFullWidthKatakanaInputMode |
       
 10450                                     EAknEditorHiraganaKanjiInputMode |
       
 10451                                     EAknEditorHiraganaInputMode))
       
 10452                 {
       
 10453                 iPermittedInputModes |= EAknEditorTextInputMode;
       
 10454                 }
       
 10455             if ( iPermittedInputModes & EAknEditorFullWidthNumericInputMode )
       
 10456                 {
       
 10457                 iPermittedInputModes |= EAknEditorNumericInputMode;
       
 10458                 }
       
 10459 
       
 10460             if ( !(defaultInputMode & (EAknEditorTextInputMode | EAknEditorNumericInputMode)))
       
 10461                 {
       
 10462                 if (defaultInputMode & (EAknEditorKatakanaInputMode |
       
 10463                                     EAknEditorHalfWidthTextInputMode|
       
 10464                                     EAknEditorFullWidthTextInputMode |
       
 10465                                     EAknEditorFullWidthKatakanaInputMode |
       
 10466                                     EAknEditorHiraganaKanjiInputMode |
       
 10467                                     EAknEditorHiraganaInputMode))
       
 10468                     {
       
 10469                     defaultInputMode = EAknEditorTextInputMode;
       
 10470                     }
       
 10471                 else if (defaultInputMode & EAknEditorFullWidthNumericInputMode)
       
 10472                     {
       
 10473                     defaultInputMode = EAknEditorNumericInputMode;
       
 10474                     }
       
 10475                 }
       
 10476             }
       
 10477         }
       
 10478 
       
 10479     // object provider items
       
 10480     iEditMenuBar = NULL;
       
 10481     editorState->SetMenu();
       
 10482     editorState->SetCba();
       
 10483 
       
 10484 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
 10485     iOptionsMenuBar = NULL;
       
 10486 #endif    
       
 10487 
       
 10488     SetWesternPredictive(iSharedDataInterface->PredictiveTextOn());
       
 10489     //check that we don't have a Chinese find mode saved to an editor that is
       
 10490     //not a Chinese find pane
       
 10491     __ASSERT_DEBUG( !((editorMode == EZhuyinFind || editorMode == EStrokeFind) &&
       
 10492         !(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes))
       
 10493         , AknFepPanic(EAknFepPanicFindModeSavedToNonFindEditor));
       
 10494 
       
 10495     ReadHashKeyLoopL();
       
 10496 
       
 10497     UpdateNumericEditorDigitType();
       
 10498     if ( IsMfneEditor() ) 
       
 10499         {
       
 10500         UpdateLocalDigitMode();
       
 10501         }
       
 10502     
       
 10503     if (editorMode) //should be an editor that has been used before
       
 10504         {
       
 10505         if (IsFlagSet(EFlagNewSharedDataInputMode) && (IsModePermitted(sharedDataMode)) && !IsKoreanInputLanguage()
       
 10506                 && (!(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)))
       
 10507             {
       
 10508             
       
 10509                 {
       
 10510                 //change to global mode, except in Find Pane, where we ignore
       
 10511                 //GS setting
       
 10512                 TryChangeModeL(sharedDataMode);
       
 10513                 ClearFlag(EFlagNewSharedDataInputMode);
       
 10514                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10515                 if (sharedDataMode == ELatinText)
       
 10516                     {
       
 10517                     editorState->SetFlags( editorState->Flags() & ~EFlagSupressAutoUpdate );
       
 10518                     }
       
 10519                 }
       
 10520             }
       
 10521 
       
 10522         // Next two cases are apps/UI intitialinsg their editors in the
       
 10523         // with the modes defined in uikon.hrh, change these to an appropriate
       
 10524         // FEP mode
       
 10525         else if (editorMode == EAknEditorNumericInputMode)
       
 10526             {
       
 10527             iCharWidth = EHalfWidthChar;
       
 10528             if ( (iMode == ENumber || iMode == ENativeNumber) && 
       
 10529                  IsModePermitted(iMode))
       
 10530                 {
       
 10531                 TryChangeModeL( iMode );
       
 10532                 }
       
 10533             else if ( IsInputModeAvailable(ENativeNumber) &&
       
 10534                  ( iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic || 
       
 10535                    iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ||
       
 10536                    iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ) )
       
 10537                 {
       
 10538                 TryChangeModeL( ENativeNumber );
       
 10539                 }
       
 10540             else
       
 10541                 {
       
 10542                 TryChangeModeL( ENumber );
       
 10543                 }
       
 10544             }
       
 10545         else if (editorMode == EAknEditorSecretAlphaInputMode)
       
 10546             {
       
 10547             //this is safe default as it is currently allowed in all FEPs
       
 10548             SetWesternPredictive(EFalse);
       
 10549             TryChangeModeL(ELatin);
       
 10550             }
       
 10551         else if (editorMode == EAknEditorTextInputMode)
       
 10552             {        
       
 10553             if (IsKoreanInputLanguage())
       
 10554             	{
       
 10555                 if(iMode == EHangul || iMode == ENumber || iMode == EAknEditorNullInputMode )
       
 10556             		{
       
 10557             		SetWesternPredictive(EFalse);
       
 10558          			TryChangeModeL(EHangul);
       
 10559             		}
       
 10560             	else
       
 10561             		{
       
 10562             		TryChangeModeL(ELatin);
       
 10563             		}
       
 10564             	}
       
 10565             else
       
 10566             	{
       
 10567             	//this is safe default as it is currently allowed in all FEPs
       
 10568             	TryChangeModeL(ELatin); 
       
 10569             	}
       
 10570             }
       
 10571         else if (!iStrokeUsedInQWERTY)
       
 10572         	{
       
 10573         	if (editorMode == EStroke && sharedDataMode == ECangJie)
       
 10574         		{
       
 10575         		TryChangeModeL(sharedDataMode);
       
 10576         		}
       
 10577         	else
       
 10578         		{
       
 10579         		TryChangeModeL(editorMode);
       
 10580         		}
       
 10581         	}
       
 10582         else  //normal case, use locally stored mode
       
 10583             {
       
 10584             if (editorMode == ECangJie && sharedDataMode == ECangJie && iQwertyInputMode)
       
 10585             	{
       
 10586             	TryChangeModeL(EStroke);
       
 10587             	}
       
 10588             else
       
 10589             	{
       
 10590             	TryChangeModeL(editorMode);
       
 10591             	}
       
 10592             }
       
 10593         }
       
 10594     else if ((iAknEditorFlags & EAknEditorFlagForceTransparentFepModes) 
       
 10595               && !IsFeatureSupportedJapanese())  //new find pane
       
 10596         {
       
 10597         // the default chinese find mode is the first mode in the hash key loop, except PrcChinese
       
 10598         if( iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
 10599             {
       
 10600             // Fix bug EHST-6DBFUJ: Default searching language shall be ELatin
       
 10601             // Changed from EPinyin to ELatin here
       
 10602             TryChangeModeL(ELatin);
       
 10603             }
       
 10604         else
       
 10605             {
       
 10606             TryChangeModeL(iHashKeyLoop[0]); 
       
 10607             }
       
 10608         }
       
 10609     else    //new editor
       
 10610         {
       
 10611         if (defaultInputMode == EAknEditorNumericInputMode)
       
 10612             {
       
 10613             //numeric mode is not saved to/retreived from shared data
       
 10614             iCharWidth = EHalfWidthChar;
       
 10615             
       
 10616             if( IsInputModeAvailable(ENativeNumber) && 
       
 10617                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10618                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10619                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10620                 {
       
 10621                 TryChangeModeL( ENativeNumber );
       
 10622                 }
       
 10623             else
       
 10624                 {
       
 10625                 TryChangeModeL( ENumber );
       
 10626                 }
       
 10627             }
       
 10628         else if ((defaultInputMode == EAknEditorTextInputMode) &&
       
 10629                  ((iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) ||
       
 10630                  (iAknEditorFlags & EAknEditorFlagNoT9)))
       
 10631             {
       
 10632             //Chinese Modes or Western Predictive mode not allowed.
       
 10633             //See if we are ok going to the current shared data mode,
       
 10634             //otherwise go for a safe default
       
 10635             if (TryChangeModeL(sharedDataMode))
       
 10636                 {
       
 10637                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10638                 }
       
 10639             else
       
 10640                 {
       
 10641                 TryChangeModeL(ELatin);
       
 10642                 }
       
 10643             }
       
 10644         else if (defaultInputMode == EAknEditorHalfWidthTextInputMode)
       
 10645             {
       
 10646             iCharWidth = EHalfWidthChar;
       
 10647             TryChangeModeL(ELatin);
       
 10648             }
       
 10649         else if (defaultInputMode == EAknEditorHiraganaInputMode)
       
 10650             {
       
 10651             TryChangeModeL(EHiragana);
       
 10652             }
       
 10653         else if (  iLanguageCapabilities.iInputLanguageCode == ELangJapanese
       
 10654               && (defaultInputMode == EAknEditorKatakanaInputMode
       
 10655               || defaultInputMode == EAknEditorFullWidthKatakanaInputMode))
       
 10656             {
       
 10657             iCharWidth = (defaultInputMode == EAknEditorKatakanaInputMode)?
       
 10658                                 EHalfWidthChar : EFullWidthChar;
       
 10659             TryChangeModeL(EKatakana);
       
 10660             }
       
 10661         else if (defaultInputMode == EAknEditorFullWidthTextInputMode)
       
 10662             {
       
 10663             iCharWidth = EFullWidthChar;
       
 10664             TryChangeModeL(ELatin);
       
 10665             }
       
 10666         else if (defaultInputMode == EAknEditorFullWidthNumericInputMode)
       
 10667             {
       
 10668             iCharWidth = EFullWidthChar;
       
 10669             if( IsInputModeAvailable(ENativeNumber) && 
       
 10670                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10671                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10672                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10673                 {
       
 10674                 TryChangeModeL( ENativeNumber );
       
 10675                 }
       
 10676             else
       
 10677                 {
       
 10678                 TryChangeModeL( ENumber );
       
 10679                 }
       
 10680             }
       
 10681         else if (defaultInputMode == EAknEditorTextInputMode 
       
 10682             && iLanguageCapabilities.iInputLanguageCode == ELangHindi )
       
 10683             {
       
 10684             TryChangeModeL( EHindi );
       
 10685             }
       
 10686         else // Default input mode is EAknEditorTextInputMode
       
 10687             {
       
 10688             // Check possibility move this section on else if
       
 10689             if (IsKoreanInputLanguage())
       
 10690             	{
       
 10691             	TryChangeModeL(EHangul);
       
 10692             	}
       
 10693             else if (TryChangeModeL(sharedDataMode))
       
 10694                 {
       
 10695                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10696                 }
       
 10697             else
       
 10698                 {
       
 10699                 TryChangeModeL(ELatin);
       
 10700                 }
       
 10701                 
       
 10702             }
       
 10703         }
       
 10704 
       
 10705     if (!iMode)
       
 10706         {
       
 10707         // If mode change wasn't successful, try latin mode as fallback.
       
 10708         TryChangeModeL(ELatin);             
       
 10709         }
       
 10710 
       
 10711     // if also fallback fails, panic.
       
 10712     __ASSERT_DEBUG(iMode, AknFepPanic(EAknFepPanicNoPermittedEditorModesAvailable));
       
 10713 
       
 10714     if (iCaseMan && !latinCaseSet)
       
 10715         {
       
 10716         iCaseMan->ConfigureCaseStateFromEditorState();
       
 10717         if ( (editorState->Flags() & EFlagSupressAutoUpdate) ||
       
 10718             editorMode == EAknEditorSecretAlphaInputMode )
       
 10719             {
       
 10720             SetFlag(EFlagSupressAutoUpdate);
       
 10721             }
       
 10722         else
       
 10723             {
       
 10724             ClearFlag(EFlagSupressAutoUpdate);
       
 10725             }
       
 10726         }
       
 10727     if ((iAknEditorFlags & EAknEditorFlagForceTransparentFepModes) &&
       
 10728         IsChineseInputLanguage() && iCaseMan != NULL )
       
 10729         {
       
 10730         SetFlag(EFlagSupressAutoUpdate);
       
 10731         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
 10732         }
       
 10733 
       
 10734     UpdateEditorContext();
       
 10735 
       
 10736     // Check if this editor was previously inline editing
       
 10737     if ( WesternPredictive() && editorState->CurrentInlineEditSpan().Length())
       
 10738         { // restore the fep to an inline editing state
       
 10739         iUncommittedText = editorState->CurrentInlineEditSpan();
       
 10740         TInt docLenFep=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10741         if (iUncommittedText.iCursorPos>docLenFep)
       
 10742             iUncommittedText.iCursorPos=docLenFep;
       
 10743         if (iUncommittedText.iAnchorPos>docLenFep)
       
 10744             iUncommittedText.iAnchorPos=docLenFep;
       
 10745 
       
 10746         TBuf<EMaximumFepWordLength> textToUncommit;
       
 10747         iInputCapabilities.FepAwareTextEditor()->
       
 10748             GetEditorContentForFep(textToUncommit, iUncommittedText.iAnchorPos, 
       
 10749                                    Min(iUncommittedText.Length(), EMaximumFepWordLength));
       
 10750 
       
 10751         // Activates western predictive UI to an inline editing state.
       
 10752         FepUI()->ActivateUI();
       
 10753         SyncStates(EAknFepStateUIActive);
       
 10754         TInt err = iPtiEngine->SetCurrentWord(textToUncommit);
       
 10755 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10756         // Predictive QWERTY (XT9) changes (TEST) ---->
       
 10757         // The PtiXt9Core may choose to ignore the SetCurrentInputSequence() call.
       
 10758         // Make sure our text buffer is in sync with the one in PtiEngine.
       
 10759         if(KErrNone != err)
       
 10760         	textToUncommit = iPtiEngine->CurrentWord();
       
 10761         TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10762         if((maxEdSize > 0) && (iUncommittedText.iAnchorPos + textToUncommit.Length() > maxEdSize))
       
 10763         {
       
 10764         	textToUncommit.SetLength(maxEdSize - iUncommittedText.iAnchorPos);
       
 10765         	iUncommittedText.iCursorPos = maxEdSize;
       
 10766         }	
       
 10767         // Predictive QWERTY (XT9) changes <----
       
 10768 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10769         StartInlineEditL(iUncommittedText, textToUncommit, textToUncommit.Length(), EFalse);
       
 10770        
       
 10771         // Make sure editor character case in sync
       
 10772         if( iUncommittedText.iAnchorPos == 0 )
       
 10773         	iCaseMan->UpdateCase(ENullNaviEvent);
       
 10774         
       
 10775         }
       
 10776 
       
 10777     if (editorState != iPreviousEditorState)
       
 10778         {
       
 10779         // we have changed editor, time to update local digits mode
       
 10780         UpdateLocalDigitMode(); 
       
 10781         iPreviousEditorState = editorState;
       
 10782         }
       
 10783 
       
 10784     if(IsExtendedFlagSet(EExtendedFlagShiftReleasedOnPopup) && !(iAknEditorFlags & EAknEditorFlagFindPane) )
       
 10785         {
       
 10786         // If in FEP context, shift is released on a non fep aware dialog
       
 10787         // like "text copied to clipboard", then release the shift 
       
 10788         // when the editor comes in focus by simulating shift up event.
       
 10789         ClearExtendedFlag(EExtendedFlagShiftReleasedOnPopup);
       
 10790         TKeyEvent shiftUp = {0, EStdKeyLeftShift, 0, 0};
       
 10791         CCoeEnv::Static()->SimulateKeyEventL(shiftUp, EEventKeyUp);     
       
 10792         }
       
 10793     else if (IsFlagSet(EFlagLongShiftKeyPress) && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
 10794         {
       
 10795         // Find pane editor does not require any shift simulation
       
 10796         
       
 10797         // After the "text copied" note and if the shift key was not released
       
 10798         // then simulate shift down event.
       
 10799         TKeyEvent shiftDown = {0, EStdKeyLeftShift, 0, 0};
       
 10800         CCoeEnv::Static()->SimulateKeyEventL(shiftDown, EEventKeyDown);      
       
 10801         if((!iCandidatePopup) && (KeyboardLayout() != EPtiKeyboard12Key ))
       
 10802         ResetShiftKeyMonitorL();
       
 10803         }
       
 10804 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10805     TransferFepStateToEditorL(EFalse); // ensure editor has up to date state
       
 10806 #else
       
 10807     TransferFepStateToEditorL(); // ensure editor has up to date state
       
 10808 #endif   
       
 10809     
       
 10810     iHashKeyMan->ResetIndicHashKeyStateL();
       
 10811     ClearExtendedFlag(EExtendedFlagShortPressHashKey);
       
 10812     }
       
 10813 
       
 10814 TInt CAknFepManager::ConfigureFepModeFromEditorMode(TInt aEditorMode)
       
 10815     {
       
 10816     TInt fepMode(aEditorMode);
       
 10817 
       
 10818     switch (aEditorMode)
       
 10819         {
       
 10820         case EAknEditorNumericInputMode:
       
 10821             if( IsInputModeAvailable(ENativeNumber) && 
       
 10822                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10823                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10824                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10825                 {
       
 10826                 fepMode = ENativeNumber;
       
 10827                 }
       
 10828             else
       
 10829                 {
       
 10830                 fepMode = ENumber;
       
 10831                 }
       
 10832             iCharWidth = EHalfWidthChar;
       
 10833             break;
       
 10834         case EAknEditorSecretAlphaInputMode:
       
 10835         case EAknEditorTextInputMode:
       
 10836         case EAknEditorHalfWidthTextInputMode:
       
 10837             fepMode = ELatin;
       
 10838             iCharWidth = EHalfWidthChar;
       
 10839             break;
       
 10840         case EAknEditorKatakanaInputMode:
       
 10841             fepMode = EKatakana;
       
 10842             iCharWidth = EHalfWidthChar;
       
 10843             break;
       
 10844         case EAknEditorFullWidthTextInputMode:
       
 10845             fepMode = ELatin;
       
 10846             iCharWidth = EFullWidthChar;
       
 10847             break;
       
 10848         case EAknEditorFullWidthKatakanaInputMode:
       
 10849             fepMode = EKatakana;
       
 10850             iCharWidth = EFullWidthChar;
       
 10851             break;
       
 10852         case EAknEditorFullWidthNumericInputMode:
       
 10853             if( IsInputModeAvailable(ENativeNumber) && 
       
 10854                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10855                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10856                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10857                 {
       
 10858                 fepMode = ENativeNumber;
       
 10859                 }
       
 10860             else
       
 10861                 {
       
 10862                 fepMode = ENumber;
       
 10863                 }
       
 10864             iCharWidth = EFullWidthChar;
       
 10865             break;
       
 10866         case EAknEditorHiraganaKanjiInputMode:
       
 10867             fepMode = EHiraganaKanji;
       
 10868             break;
       
 10869         case EAknEditorHiraganaInputMode:
       
 10870             fepMode = EHiragana;
       
 10871             break;
       
 10872         default:
       
 10873             break;
       
 10874         }
       
 10875     return fepMode;
       
 10876     }
       
 10877 
       
 10878 void CAknFepManager::LaunchHelpTextQueryL()
       
 10879     {
       
 10880     TUid fepUid = CCoeEnv::Static()->FepUid();  
       
 10881     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 10882     iUiInterface->LaunchHelpTextQueryL(R_AKNFEP_HELP_TEXT);
       
 10883     PrepareFepAfterDialogExitL(fepUid);
       
 10884     }
       
 10885 
       
 10886 void CAknFepManager::UpdateEditorContext() const
       
 10887     {
       
 10888     if(EditingStateIndicator())
       
 10889         {
       
 10890         iUiInterface->UpdateEditorContext(*EditingStateIndicator(), *FepUI());
       
 10891         }
       
 10892     }
       
 10893 
       
 10894 TBool CAknFepManager::TextIsValidInEditor(const TDesC& aText)
       
 10895     {
       
 10896     TBool ret = ETrue;
       
 10897     TUint length = aText.Length();
       
 10898     TCoeInputCapabilities::MCoeFepSpecificExtensions* ipCapExt = 
       
 10899                            iInputCapabilities.FepSpecificExtensions(TUid::Uid(EAknFepUid));
       
 10900     if (ipCapExt)
       
 10901         {
       
 10902         while(length--)
       
 10903             {
       
 10904             if (!ipCapExt->IsValidCharacter(aText[length]))
       
 10905                 {
       
 10906                 ret = EFalse;
       
 10907                 }
       
 10908             }
       
 10909         }
       
 10910     return ret;
       
 10911     }
       
 10912 
       
 10913 TBool CAknFepManager::CharIsValidInEditor(TChar aChar)
       
 10914     {
       
 10915     TBool ret = ETrue;
       
 10916     TCoeInputCapabilities::MCoeFepSpecificExtensions* ipCapExt = 
       
 10917                            iInputCapabilities.FepSpecificExtensions(TUid::Uid(EAknFepUid));
       
 10918     if (ipCapExt)
       
 10919         {
       
 10920         if (!ipCapExt->IsValidCharacter(aChar))
       
 10921             {
       
 10922             ret = EFalse;
       
 10923             }
       
 10924         }
       
 10925     return ret;
       
 10926     }
       
 10927 
       
 10928 void CAknFepManager::SetCursorType(TChineseFepCursorType aType)
       
 10929     {
       
 10930     TBool setToTrue = ETrue;
       
 10931     TTextCursor newCursor;
       
 10932 
       
 10933     newCursor.iType=TTextCursor::ETypeRectangle;
       
 10934     if (aType == EPassive)
       
 10935         {
       
 10936         newCursor.iType=TTextCursor::ETypeHollowRectangle;
       
 10937         }
       
 10938     if ( IsFepAwareTextEditor() )
       
 10939         {
       
 10940         iInputCapabilities.FepAwareTextEditor()->Extension1()->SetCursorType(setToTrue, newCursor);
       
 10941         }
       
 10942     }
       
 10943 
       
 10944 MAknEditingStateIndicator* CAknFepManager::EditingStateIndicator() const
       
 10945     {
       
 10946     MAknEditingStateIndicator* indicator = NULL;
       
 10947 
       
 10948     // First ask indicator from controls owning the editor.
       
 10949     // For example CAknQueryControl and CAknSearchField implement
       
 10950     // their own indicators.
       
 10951 
       
 10952     MObjectProvider* objectProvider = NULL;
       
 10953 
       
 10954     // First try through CAknEdwinState object.
       
 10955     // It exists with CEikEdwin-derived editors.
       
 10956     
       
 10957 		MCoeFepAwareTextEditor* editor = NULL;
       
 10958 		MCoeFepAwareTextEditor_Extension1* ext1 = NULL;
       
 10959 		CAknEdwinState* state = NULL;
       
 10960 
       
 10961     editor = iInputCapabilities.FepAwareTextEditor();
       
 10962     
       
 10963     if(editor)
       
 10964     	ext1 = editor->Extension1() ;
       
 10965     if(ext1)
       
 10966       state = (CAknEdwinState*)ext1->State( KNullUid ) ;
       
 10967       
       
 10968     if ( IsFepAwareTextEditor() && ( editor  ) && ( ext1) && ( state ))
       
 10969         {
       
 10970         objectProvider = state->ObjectProvider();
       
 10971         }
       
 10972 
       
 10973     // If not found, try to get object provider from input capabilities.
       
 10974     // It is set there with CEikMfne-derived editors.
       
 10975 
       
 10976     if ( !objectProvider )
       
 10977         {
       
 10978         objectProvider = iInputCapabilities.ObjectProvider();
       
 10979         }
       
 10980 
       
 10981     if ( objectProvider )
       
 10982         {
       
 10983         indicator = objectProvider->MopGetObject( indicator );
       
 10984         }
       
 10985 
       
 10986     // If no indicator was supplied, get one from CAknEnv.
       
 10987     // By default, this one is FEP's own indicator.
       
 10988 
       
 10989     if ( !indicator )
       
 10990         {
       
 10991         indicator = CAknEnv::Static()->EditingStateIndicator();
       
 10992         if (indicator != iIndicator)
       
 10993             {
       
 10994             CAknEnv::Static()->SwapEditingStateIndicator(iIndicator);
       
 10995             indicator = iIndicator;
       
 10996             }
       
 10997         }
       
 10998 
       
 10999     return indicator;
       
 11000     }
       
 11001 
       
 11002 TBool CAknFepManager::TryHandleArrowRightEventL(TInt aDokumentLength)
       
 11003     {
       
 11004     TBool ret = EFalse;
       
 11005     TBool thai = (iLanguageCapabilities.iInputLanguageCode == ELangThai);
       
 11006     if (  iInputCapabilities.FepAwareTextEditor() &&
       
 11007           (iSharedDataInterface->SpaceWithScrollRight() || thai ) &&
       
 11008           (!(iAknEditorFlags & EAknEditorFlagNoLRNavigation)) &&
       
 11009           iFepManState == EAknFepStateInitial &&
       
 11010           (!IsFlagSet(EFlagInsideInlineEditingTransaction) ) &&
       
 11011           (!IsFlagSet(EFlagShiftKeyDepressed)) &&
       
 11012           iMode != EHiragana )          //  Not supported in only Hiragana input mode
       
 11013         {
       
 11014         TInt cursorPos = DocPos().iPos;
       
 11015         TCursorSelection cursorSel;
       
 11016         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11017         if (( cursorPos == aDokumentLength)
       
 11018             && !cursorSel.Length()
       
 11019             && (IsFeatureSupportedJapanese() || (PreviousChar() != 0x0020)) )
       
 11020             {
       
 11021             // set to half-width space or full-width space by current input mode.
       
 11022             //    0x0020 is unicode for half-width space
       
 11023             //    0x3000 is unicode for full-width space
       
 11024             TUint code(0);
       
 11025             switch (iMode)
       
 11026                 {
       
 11027                 case EHiraganaKanji:
       
 11028                     code = 0x3000;
       
 11029                     break;
       
 11030                 case ELatin:
       
 11031                     code = (!WesternPredictive() && iCharWidth == EFullWidthChar)?
       
 11032                             0x3000 : 0x0020;
       
 11033                     break;
       
 11034                 case EHiragana:
       
 11035                     // Not supported in only Hiragana input mode
       
 11036                     break;
       
 11037                 case EHangul:
       
 11038                 	code = 0x0020;
       
 11039                 	break;
       
 11040                 case ENumber:
       
 11041                 case ENativeNumber:
       
 11042                 case EKatakana:
       
 11043                 default:
       
 11044                     code = (iCharWidth == EFullWidthChar)? 0x3000 : 0x0020;
       
 11045                     break;
       
 11046                 }
       
 11047             if (code)
       
 11048                 {
       
 11049                 SimulateKeyEventL(code); // add a space
       
 11050                 SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11051                 ret = ETrue;
       
 11052                 }
       
 11053             }
       
 11054         }
       
 11055     return ret;
       
 11056     }
       
 11057 
       
 11058 TBool CAknFepManager::TryHandleArrowLeftEventL(TInt aDokumentLength)
       
 11059     {
       
 11060     TBool ret = EFalse;
       
 11061     if (iInputCapabilities.FepAwareTextEditor() &&
       
 11062         iSharedDataInterface->SpaceWithScrollRight() &&
       
 11063         (!(iAknEditorFlags & EAknEditorFlagNoLRNavigation)) &&
       
 11064         iFepManState == EAknFepStateInitial &&
       
 11065         (!IsFlagSet(EFlagInsideInlineEditingTransaction) ) &&
       
 11066         (!IsFlagSet(EFlagShiftKeyDepressed)) &&
       
 11067         iMode != EHiragana )          //  Not supported in only Hiragana input mode
       
 11068         {
       
 11069         TInt cursorPos = DocPos().iPos;
       
 11070         TCursorSelection cursorSel;
       
 11071         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11072         TText previousChar = PreviousChar();
       
 11073         if (( cursorPos == aDokumentLength)
       
 11074             && !cursorSel.Length()
       
 11075             && (IsFeatureSupportedJapanese()
       
 11076             && (previousChar == 0x3000 || previousChar == 0x0020) )) // full width or half-width space.
       
 11077             {
       
 11078             SimulateKeyEventL(EKeyBackspace);
       
 11079             SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11080             ret = ETrue;
       
 11081             }
       
 11082         }
       
 11083     return ret;
       
 11084     }
       
 11085 
       
 11086 TBool CAknFepManager::TryHandleArrowDownEventL(TInt aDokumentLength)
       
 11087     {
       
 11088     TBool ret = EFalse;
       
 11089 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11090     // Predictive QWERTY (XT9) changes ---->
       
 11091     if ( iWesternPredictive &&
       
 11092          IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) && !(iAknEditorFlags & EAknEditorFlagNoT9) 
       
 11093          && !IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) && !IsFlagSet(EFlagNoMatches))
       
 11094         {
       
 11095         LaunchCandidatePopupListL();
       
 11096         ret = ETrue;
       
 11097         }
       
 11098     // Predictive QWERTY (XT9) changes <----
       
 11099     else 
       
 11100 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 11101     if  ( ( iAknEditorFlags & EAknEditorFlagAllowEntersWithScrollDown ) &&
       
 11102           iInputCapabilities.FepAwareTextEditor() &&
       
 11103           ( iSharedDataInterface->EntersWithScrollDown() ) &&
       
 11104           iFepManState == EAknFepStateInitial &&
       
 11105           !IsFlagSet(EFlagInsideInlineEditingTransaction) &&
       
 11106           !IsFlagSet(EFlagShiftKeyDepressed) )
       
 11107         {
       
 11108         TInt cursorPos = DocPos().iPos;
       
 11109         TCursorSelection cursorSel;
       
 11110         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11111         if ( cursorPos == aDokumentLength &&
       
 11112             !cursorSel.Length() )
       
 11113             {
       
 11114             SimulateKeyEventL(EKeyEnter); // add line feed
       
 11115             SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11116             ret = ETrue;
       
 11117             }
       
 11118         }
       
 11119     return ret;
       
 11120     }
       
 11121 
       
 11122 TUint CAknFepManager::EditorModeFromFepMode(TInt aFepMode)
       
 11123     {
       
 11124     TUint editorMode(aFepMode);
       
 11125     switch (aFepMode)
       
 11126         {
       
 11127         case ELatin:
       
 11128             if (iPermittedInputModes & EAknEditorTextInputMode)
       
 11129                 {
       
 11130                 editorMode = EAknEditorTextInputMode;
       
 11131                 if (IsFeatureSupportedJapanese())
       
 11132                     {
       
 11133                     if (iCharWidth == EHalfWidthChar 
       
 11134                     && (iPermittedInputModes & EAknEditorHalfWidthTextInputMode))
       
 11135                         {
       
 11136                         editorMode = EAknEditorHalfWidthTextInputMode;
       
 11137                         }
       
 11138                     else if (iCharWidth == EFullWidthChar 
       
 11139                          && (iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 11140                         {
       
 11141                         editorMode = EAknEditorFullWidthTextInputMode;
       
 11142                         }
       
 11143                     }
       
 11144                 }
       
 11145             else if (iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
 11146                 {
       
 11147                 editorMode = EAknEditorTextInputMode;
       
 11148                 if (IsFeatureSupportedJapanese())
       
 11149                     {
       
 11150                     editorMode = EAknEditorHalfWidthTextInputMode;
       
 11151                     if (iCharWidth == EFullWidthChar 
       
 11152                      &&(iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 11153                         {
       
 11154                         editorMode = EAknEditorFullWidthTextInputMode;
       
 11155                         }
       
 11156                     }
       
 11157                 }
       
 11158             else if (iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
 11159                 {
       
 11160                 editorMode = EAknEditorTextInputMode;
       
 11161                 if (IsFeatureSupportedJapanese())
       
 11162                     {
       
 11163                     editorMode = EAknEditorFullWidthTextInputMode;
       
 11164                     }
       
 11165                 }
       
 11166             else
       
 11167                 {
       
 11168                 editorMode = EAknEditorSecretAlphaInputMode;
       
 11169                 }
       
 11170             break;
       
 11171         case ENumber:
       
 11172         case ENativeNumber:
       
 11173             editorMode = EAknEditorNumericInputMode;
       
 11174             if (iCharWidth == EFullWidthChar 
       
 11175             && (iPermittedInputModes & EAknEditorFullWidthNumericInputMode))
       
 11176                 {
       
 11177                 editorMode = EAknEditorFullWidthNumericInputMode;
       
 11178                 }
       
 11179             break;
       
 11180     	case EHangul: 
       
 11181        		editorMode = EAknEditorTextInputMode;       	
       
 11182        		break;
       
 11183         default:
       
 11184             if (IsFeatureSupportedJapanese())
       
 11185                 {
       
 11186                 editorMode = EditorMode(aFepMode, iCharWidth);
       
 11187                 }
       
 11188             break;
       
 11189         }
       
 11190     return editorMode;
       
 11191     }
       
 11192 
       
 11193 CAknKeySoundSystem* CAknFepManager::SoundSystem() const
       
 11194     {
       
 11195     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 11196     if (coeEnv->AppUi())
       
 11197         {
       
 11198         return iAvkonAppUiBase->KeySounds();
       
 11199         }
       
 11200     return NULL;
       
 11201     }
       
 11202 
       
 11203 void CAknFepManager::SetHashKeyStyle()
       
 11204     {
       
 11205     CAknFepHashKeyManager::THashKeyStyle style = CAknFepHashKeyManager::EHashKeyStyleWestern;
       
 11206 
       
 11207     switch (iLanguageCapabilities.iInputLanguageCode)
       
 11208         {
       
 11209         case ELangPrcChinese:
       
 11210         case ELangHongKongChinese:
       
 11211         case ELangTaiwanChinese:
       
 11212             style = CAknFepHashKeyManager::EHashKeyStyleChineseWithWestern;
       
 11213             break;
       
 11214         case ELangJapanese:
       
 11215             style = CAknFepHashKeyManager::EHashKeyStyleJapanese;
       
 11216             break;
       
 11217         case ELangKorean:
       
 11218         	style = CAknFepHashKeyManager::EHashKeyStyleKoreanWithWestern;
       
 11219         	break;
       
 11220         default:
       
 11221             break;
       
 11222         }
       
 11223 
       
 11224     iHashKeyMan->SetHashKeyStyle( style );
       
 11225     }
       
 11226 
       
 11227 void CAknFepManager::ReadHashKeyLoopL()
       
 11228     {
       
 11229     iHashKeyLoop.Reset();
       
 11230 
       
 11231     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 11232     TResourceReader reader;
       
 11233     coeEnv->CreateResourceReaderLC(reader, R_HASH_KEY_LOOP_ALL_INPUT_MODES);
       
 11234 
       
 11235     iVariantPermittedModes = 0;
       
 11236     const TInt count = reader.ReadInt16();
       
 11237     for (TInt ii=0; ii<count; ii++)
       
 11238         {
       
 11239         TInt mode = reader.ReadInt32();
       
 11240         if ( IsInputModeAvailable(mode) )
       
 11241             {
       
 11242             if ( mode == EPRCFind)
       
 11243                 {
       
 11244                 mode = ELatin;
       
 11245                 }
       
 11246             iHashKeyLoop.Append(mode);
       
 11247             iVariantPermittedModes |= mode;
       
 11248             }
       
 11249         }
       
 11250     CleanupStack::PopAndDestroy(); //reader
       
 11251     }
       
 11252 
       
 11253 TBool CAknFepManager::IsValidInLineCharacter(TChar aCharacter) const
       
 11254     {
       
 11255     TBool validInlineCharacter = ETrue;
       
 11256     TChar::TCategory category = aCharacter.GetCategory();
       
 11257     TChar::TBdCategory bdCategory = aCharacter.GetBdCategory();
       
 11258     switch (iLanguageCapabilities.iInputLanguageCode)
       
 11259         {
       
 11260         case ELangArabic:
       
 11261             {
       
 11262             // Needs more specific category
       
 11263             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11264                 (bdCategory == TChar::ERightToLeftArabic) );
       
 11265             break;
       
 11266             }
       
 11267         case ELangHebrew:
       
 11268             {
       
 11269             // Needs more specific category
       
 11270             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11271                 (bdCategory == TChar::ERightToLeft) );
       
 11272             break;
       
 11273             }
       
 11274         case ELangFarsi:
       
 11275         case ELangUrdu:
       
 11276             {
       
 11277             // Needs more specific category
       
 11278             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11279                 (bdCategory == TChar::ERightToLeftArabic) );
       
 11280             break;
       
 11281             }
       
 11282             /*Hindi*/            
       
 11283         case ELangHindi:
       
 11284 #ifdef RD_MARATHI
       
 11285 			/* Same for Marathi */
       
 11286         case ELangMarathi:
       
 11287 #endif
       
 11288             {
       
 11289             // Needs more specific category
       
 11290             validInlineCharacter = IsValidInlineIndicCharacter(aCharacter);
       
 11291             
       
 11292             break;
       
 11293             }
       
 11294         case ELangVietnamese:
       
 11295             {
       
 11296             validInlineCharacter = (aCharacter.IsAlpha() &&
       
 11297                                     !((category & TChar::ELetterOtherGroup))) ||
       
 11298                                     ((category == TChar::EMarkGroup) && 
       
 11299                                     (bdCategory == TChar::ENonSpacingMark));
       
 11300             break;
       
 11301             }
       
 11302         case ELangThai:
       
 11303             {
       
 11304             validInlineCharacter = (!(aCharacter.IsSpace() || (aCharacter == 0x2029))) &&
       
 11305                                    ((aCharacter.IsAlpha() && 
       
 11306                                     !(category & TChar::ELetterOtherGroup)) ||
       
 11307                                    ((category & TChar::EMarkGroup) && 
       
 11308                                     (bdCategory == TChar::ENonSpacingMark)) ||
       
 11309                                    ((category & TChar::ELetterModifierGroup) && 
       
 11310                                     (bdCategory == TChar::ELeftToRight)) ||
       
 11311                                    ((category & TChar::ESeparatorGroup ) && 
       
 11312                                     (bdCategory == TChar::EWhitespace))||
       
 11313                                    ((category & TChar::EMcCategory) && 
       
 11314                                     (bdCategory == TChar::ELeftToRight)));
       
 11315             break;                                    
       
 11316             }
       
 11317         case ELangTaiwanChinese:
       
 11318         case ELangHongKongChinese:
       
 11319         case ELangPrcChinese:
       
 11320         case ELangEnglish:
       
 11321             {                           
       
 11322 #ifdef RD_INTELLIGENT_TEXT_INPUT   
       
 11323             // for qwerty special characters should not break the word
       
 11324             if( iQwertyInputMode && ( KeyboardLayout() !=EPtiKeyboardHalfQwerty ))
       
 11325                 {
       
 11326                 validInlineCharacter = (!( aCharacter.IsSpace() || (aCharacter == 0x2029) || 
       
 11327                                         ( aCharacter.IsAlpha() && 
       
 11328                                          (category & TChar::ELetterOtherGroup))||
       
 11329                                         ((category & TChar::EMarkGroup) && 
       
 11330                                          (bdCategory == TChar::ENonSpacingMark)) ||
       
 11331                         				((category & TChar::ELetterModifierGroup) && 
       
 11332                         		 		 (bdCategory == TChar::ELeftToRight)) ||
       
 11333                         				((category & TChar::ESeparatorGroup ) && 
       
 11334                         		 		 (bdCategory == TChar::EWhitespace))));
       
 11335                 }            
       
 11336             else                
       
 11337 #endif      // whereas for ITUT and Half Qwerty they should
       
 11338                 {
       
 11339                 validInlineCharacter = ( aCharacter.IsAlpha() && !(category & TChar::ELetterOtherGroup) );
       
 11340                 }            
       
 11341             break;
       
 11342             }
       
 11343         default:
       
 11344             {
       
 11345 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 11346 			// for qwerty special characters should not break the word
       
 11347 			
       
 11348 			if( iQwertyInputMode && ( KeyboardLayout() !=EPtiKeyboardHalfQwerty ) )
       
 11349 				{
       
 11350 				validInlineCharacter = (!(aCharacter.IsSpace() || (aCharacter == 0x2029)));	
       
 11351 				}
       
 11352 			else	            
       
 11353 #endif		// whereas for ITUT and Half Qwerty they should
       
 11354 				{
       
 11355 				validInlineCharacter = ( aCharacter.IsAlpha() && !(category & TChar::ELetterOtherGroup) );
       
 11356 				}
       
 11357 			
       
 11358 
       
 11359             break;
       
 11360             }
       
 11361         }
       
 11362 	
       
 11363 	TUint16 key = 0;
       
 11364 	if(validInlineCharacter)
       
 11365 		{
       
 11366 		validInlineCharacter = EFalse;
       
 11367         ConvertCharToKey(aCharacter, key);
       
 11368 		if(0 != key)
       
 11369 			{
       
 11370 			validInlineCharacter = ETrue;
       
 11371 			}
       
 11372 		}
       
 11373 		
       
 11374     return validInlineCharacter;
       
 11375     }
       
 11376 TBool CAknFepManager::IsValidInlineIndicCharacter(TChar aCharacter) const
       
 11377     {
       
 11378     TBool validInlineCharacter = ETrue;
       
 11379     TChar::TCategory category = aCharacter.GetCategory();
       
 11380     TChar::TBdCategory bdCategory = aCharacter.GetBdCategory();
       
 11381     
       
 11382     if(!((category == TChar::EPoCategory) || aCharacter == 0x0950 || aCharacter == 0x093D))
       
 11383         {
       
 11384         validInlineCharacter = ((( (category & TChar::ELetterOtherGroup) 
       
 11385                                       && (bdCategory == TChar::ELeftToRight) )
       
 11386                                   ||( (category & TChar::EMcCategory) 
       
 11387                                       && (bdCategory == TChar::ELeftToRight) )
       
 11388                                   ||( (category & TChar::EMarkGroup) 
       
 11389                                       && (bdCategory == TChar::ENonSpacingMark)) )
       
 11390                                  &&( ! ( aCharacter.IsAlpha() 
       
 11391                                       && !(category & TChar::ELetterOtherGroup) )));
       
 11392         }
       
 11393     else 
       
 11394         {
       
 11395         validInlineCharacter = EFalse;
       
 11396         }
       
 11397     return  validInlineCharacter;
       
 11398     }
       
 11399 
       
 11400 TInt CAknFepManager::WordConcatenationTimerTimeoutCallback(TAny* aObj)
       
 11401     {
       
 11402     TRAPD(err, static_cast<CAknFepManager*>(aObj)->WordConcatenationTimerTimeoutL());
       
 11403     if (err)
       
 11404         {
       
 11405         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 11406         return KErrNoMemory;
       
 11407         }
       
 11408     return KErrNone;
       
 11409     }
       
 11410 
       
 11411 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11412     
       
 11413 TBool CAknFepManager::IsHybridAplhaEditor() const
       
 11414     {
       
 11415     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EHybridAlphaNumericEditor);
       
 11416     return phoneIdle;
       
 11417     }
       
 11418 
       
 11419 TBool CAknFepManager::IsHybridAlphaModeChangedtoAplhanumeric() const
       
 11420     {
       
 11421     return iHybridAplphaChangedToAlphanumeric;
       
 11422     }
       
 11423 
       
 11424 TBool CAknFepManager::IsPhoneNumberEditor() const
       
 11425     {
       
 11426     TBool phoneEditor = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);
       
 11427     return phoneEditor;
       
 11428     }
       
 11429 CAknFepFnKeyManager::TFnKeyState CAknFepManager::FnKeyState()
       
 11430     {
       
 11431     return iFnKeyManager->FnKeyState();
       
 11432     }
       
 11433 void CAknFepManager::SetFnKeyState(CAknFepFnKeyManager::TFnKeyState aState)
       
 11434     {
       
 11435     iFnKeyManager->SetFnKeyState(aState);
       
 11436     }
       
 11437 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
 11438 TBool CAknFepManager::IsReverseFnkeyInput()
       
 11439     {
       
 11440     return iIsReverseFnkeyInput;
       
 11441     }
       
 11442 void CAknFepManager::SetReverseFnkeyInputMode(TBool iIsOn)
       
 11443 	{
       
 11444 	iIsReverseFnkeyInput = iIsOn;
       
 11445 	}
       
 11446 TBool CAknFepManager::IsValidCharInNumericEditorL( TChar aChar ) const
       
 11447     {
       
 11448     if(!EditorState())
       
 11449         {
       
 11450     	return EFalse;    	
       
 11451         }
       
 11452     TBool validChar = EFalse;
       
 11453     if( aChar.IsDigit() )
       
 11454         {
       
 11455         return ETrue;
       
 11456         }
       
 11457     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);            
       
 11458     if( (phoneIdle || (IsHybridAplhaEditor() && !IsHybridAlphaModeChangedtoAplhanumeric()))
       
 11459 	 	&& aChar == '#')    
       
 11460     	{
       
 11461     	return ETrue;
       
 11462     	}
       
 11463 	if( aChar == '.' && EAknEditorConverterNumberModeKeymap == iAknEditorNumericKeymap)
       
 11464         {
       
 11465         return ETrue;
       
 11466         }	
       
 11467     if( IsAllowedKeymappingForNumberMode(aChar) )
       
 11468     	{
       
 11469     	return ETrue;
       
 11470     	}
       
 11471     	
       
 11472     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();  
       
 11473     // No SCT table use default SCT
       
 11474     if( resourceSCTId == KErrNotFound || !resourceSCTId || 
       
 11475             (IsHybridAplhaEditor()&& !IsHybridAlphaModeChangedtoAplhanumeric()))
       
 11476         {
       
 11477         resourceSCTId = NumericModeSCTResourceId();
       
 11478         }   
       
 11479     
       
 11480     if( resourceSCTId )
       
 11481         {
       
 11482         TResourceReader reader;
       
 11483         CEikonEnv::Static()->CreateResourceReaderLC(reader,resourceSCTId);
       
 11484         reader.ReadInt32(); // skip sct id    
       
 11485         TPtrC chars=reader.ReadTPtrC(); // read special char        
       
 11486         validChar = ( chars.Locate(aChar)>=0 );                      
       
 11487         CleanupStack::PopAndDestroy();
       
 11488         }
       
 11489     return validChar;
       
 11490     
       
 11491     }
       
 11492 TInt CAknFepManager::GetNumericSCTResID()
       
 11493     {
       
 11494     if(!EditorState())
       
 11495       	{
       
 11496         return NumericModeSCTResourceId();
       
 11497     	  }
       
 11498     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();
       
 11499     if(resourceSCTId == KErrNotFound || !resourceSCTId )
       
 11500         {
       
 11501         resourceSCTId = NumericModeSCTResourceId();
       
 11502         }
       
 11503     return resourceSCTId;
       
 11504     }
       
 11505 
       
 11506 TBool CAknFepManager::IsValidCharForNumericInFnReverseL(TInt aKey, TPtiTextCase aCase) 
       
 11507     {
       
 11508     if(!EditorState())
       
 11509         {
       
 11510     	return EFalse;    	
       
 11511         }
       
 11512     TBuf<32> keyMaps;
       
 11513     iPtiEngine->MappingDataForKey( (TPtiKey)aKey, keyMaps, aCase);  
       
 11514     
       
 11515     TBool validKey(EFalse);   
       
 11516     if( keyMaps.Length()<= 0 )
       
 11517         {
       
 11518         return validKey;
       
 11519         }
       
 11520     TChar chr =keyMaps[0];
       
 11521     if( chr.IsDigit() )
       
 11522         {
       
 11523         return ETrue;
       
 11524         }
       
 11525 
       
 11526     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();  
       
 11527     // No SCT table use default SCT
       
 11528     if( resourceSCTId == KErrNotFound || !resourceSCTId )
       
 11529         {
       
 11530         resourceSCTId = NumericModeSCTResourceId();
       
 11531         }   
       
 11532     
       
 11533     if( resourceSCTId )
       
 11534         {
       
 11535         TResourceReader reader;
       
 11536         CEikonEnv::Static()->CreateResourceReaderLC(reader,resourceSCTId);
       
 11537         reader.ReadInt32(); // skip sct id    
       
 11538         TPtrC chars=reader.ReadTPtrC(); // read special char
       
 11539         
       
 11540         validKey = (chars.Locate(chr)>=0 );
       
 11541         if(chr.IsAlpha())
       
 11542             {
       
 11543             chr.UpperCase();
       
 11544             validKey |= (chars.Locate(chr)>=0 ) ;
       
 11545             }                 
       
 11546             
       
 11547         CleanupStack::PopAndDestroy();
       
 11548         }
       
 11549          
       
 11550     return validKey;
       
 11551     
       
 11552     }
       
 11553 #endif //__REVERSE_FN_KEY_SUPPORTED
       
 11554 void CAknFepManager::AddOneSpaceOrMoveCursorL()
       
 11555 	{
       
 11556 	if(static_cast<TChar>(NextChar()).IsSpace())
       
 11557 		{
       
 11558 		TCursorSelection sel;
       
 11559 		iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(sel);
       
 11560 		sel.iCursorPos++;
       
 11561 		sel.iAnchorPos++;
       
 11562 		iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);	                		
       
 11563 		}
       
 11564 	else if(IsEditorHasFreeSpace())
       
 11565     	{
       
 11566         SimulateKeyEventL(EKeySpace);
       
 11567     	}
       
 11568 	SimulateKeyEventL(EKeyF19);
       
 11569 	}
       
 11570 #endif
       
 11571 TBool CAknFepManager::IsOnlyNumericPermitted() const
       
 11572     {
       
 11573     if (IsFeatureSupportedJapanese())
       
 11574         {
       
 11575         return !(iPermittedInputModes & ~(EAknEditorNumericInputMode 
       
 11576                | EAknEditorFullWidthNumericInputMode) );
       
 11577         }
       
 11578     else
       
 11579         {
       
 11580         // Only non-japanese modes are considered.
       
 11581         return !( iPermittedInputModes & 
       
 11582                   (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode) );
       
 11583         }
       
 11584     }
       
 11585 
       
 11586 void CAknFepManager::TryIncrementModeL(TInt aCurrentMode)
       
 11587     {
       
 11588     //check that we are currently in the correct mode
       
 11589     __ASSERT_DEBUG(IsModePermitted(iMode),
       
 11590                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11591     __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
 11592                    AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
 11593 
       
 11594     const TInt lastModePos = iHashKeyLoop.Count()-1 ;
       
 11595     const TInt currentModePos = iHashKeyLoop.Find(aCurrentMode);
       
 11596     TInt newModePos = currentModePos;
       
 11597 
       
 11598     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11599                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11600 
       
 11601     do  {
       
 11602         if (newModePos == lastModePos)
       
 11603             {
       
 11604             //we've got to the end of the hash key loop, go back to the beginning
       
 11605             newModePos = 0;
       
 11606             }
       
 11607         else
       
 11608             {
       
 11609             newModePos++;
       
 11610             }
       
 11611 
       
 11612         if (TryChangeModeL(iHashKeyLoop[newModePos]))
       
 11613             {
       
 11614             return; //succeeded to move to next available mode
       
 11615             }
       
 11616         }
       
 11617         while (newModePos != currentModePos);
       
 11618     }
       
 11619 
       
 11620 void CAknFepManager::TryIncrementModeChineseQwertyL(TInt aCurrentMode)
       
 11621     {
       
 11622     __ASSERT_DEBUG(IsModePermitted(aCurrentMode),AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11623 
       
 11624     const TInt lastModePos = iHashKeyLoop.Count() - 1 ;
       
 11625     const TInt currentModePos = iHashKeyLoop.Find(aCurrentMode);
       
 11626     TInt newModePos = currentModePos;
       
 11627 
       
 11628     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11629                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11630 
       
 11631     do  
       
 11632         {
       
 11633         if (newModePos == lastModePos)
       
 11634             {
       
 11635             //we've got to the end of the hash key loop, go back to the beginning
       
 11636             newModePos = 0;
       
 11637             }
       
 11638         else
       
 11639             {
       
 11640             newModePos++;
       
 11641             }
       
 11642         }while(iHashKeyLoop[newModePos] == ENumber && !IsOnlyNumericPermitted()); // no number mode in Chinese qwerty input, except those editors which only support number
       
 11643             
       
 11644     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
 11645     if(TryChangeModeL(iHashKeyLoop[newModePos]))
       
 11646         {
       
 11647         return; //succeeded to move to next available mode
       
 11648         }
       
 11649     }
       
 11650 
       
 11651 void CAknFepManager::TryIncrementChineseModeForQwertyL( TInt aCurrentMode )
       
 11652     {
       
 11653     __ASSERT_DEBUG(IsModePermitted(aCurrentMode),AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11654 
       
 11655     const TInt lastModePos = iHashKeyLoop.Count() - 1;
       
 11656     const TInt currentModePos = iHashKeyLoop.Find( aCurrentMode );
       
 11657     TInt newModePos = currentModePos;
       
 11658 
       
 11659     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11660         AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11661 
       
 11662     do
       
 11663         {
       
 11664         if ( newModePos == lastModePos )
       
 11665             {
       
 11666             //we've got to the end of the hash key loop, go back to the beginning
       
 11667             newModePos = 0;
       
 11668             }
       
 11669         else
       
 11670             {
       
 11671             newModePos++;
       
 11672             }
       
 11673         }
       
 11674     while ( (iHashKeyLoop[newModePos] == ENumber
       
 11675         && !IsOnlyNumericPermitted()) || (iHashKeyLoop[newModePos] == ELatin
       
 11676         && IsChangeModeByShiftAndSpace() ) ); // no number mode and latin in Chinese qwerty input, except those editors which only support number
       
 11677 
       
 11678     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
 11679     if ( TryChangeModeL( iHashKeyLoop[newModePos] ) )
       
 11680         {
       
 11681         return; //succeeded to move to next available mode
       
 11682         }
       
 11683     }
       
 11684 
       
 11685 void CAknFepManager::TryChangeToSharedDataModeL()
       
 11686     {
       
 11687     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 11688     TryChangeModeL(sharedDataMode);
       
 11689     }
       
 11690 
       
 11691 void CAknFepManager::TryChangeToModeBeforeL()
       
 11692     {
       
 11693     if (TryChangeModeL(iModeBefore))
       
 11694         {
       
 11695         if (iModeBefore==ELatin)
       
 11696             {
       
 11697             if ( iCaseBefore )
       
 11698                 {
       
 11699                 iCaseMan->SetCurrentCase(iCaseBefore);
       
 11700                 }
       
 11701             else
       
 11702                 {
       
 11703                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 11704                 }
       
 11705             }
       
 11706         }
       
 11707     }
       
 11708 
       
 11709 #ifdef RD_HINDI_PHONETIC_INPUT    
       
 11710 
       
 11711 TBool CAknFepManager::IsIndicPhoneticInputLanguage() const
       
 11712     {
       
 11713     MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 11714     TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 11715     return (TAknFepUiIndicInputManager::IsIndicPhoneticLanguage(TLanguage(currentPtiLang)));
       
 11716     }
       
 11717 
       
 11718 void CAknFepManager::TryChangePhoneticModeL()
       
 11719     {
       
 11720     MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 11721     TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 11722     TInt lang = 0;
       
 11723     
       
 11724     (TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(TLanguage(currentPtiLang)))? 
       
 11725     lang = ELangEnglish : lang = iLanguageCapabilities.iInputLanguageCode;
       
 11726     
       
 11727     iPtiEngine->ActivateLanguageL(lang);
       
 11728     iLangMan->SetInputLanguageL(lang);
       
 11729     InternalFepUI()->SetMode(iMode, EFalse, iQwertyInputMode);  
       
 11730     iCaseMan->UpdateCase(ENullNaviEvent);
       
 11731     UpdateIndicators();
       
 11732     CommitInlineEditL();
       
 11733     }
       
 11734     
       
 11735 TInt CAknFepManager::SetPhoneticIndicator(TLanguage aInputLanguage)
       
 11736     {
       
 11737     TInt newState = 0;
       
 11738     TInt currentCase = iCaseMan->CurrentCase();
       
 11739 
       
 11740     switch(aInputLanguage)
       
 11741         {
       
 11742         case KLangHindiPhonetic: 
       
 11743             if(currentCase == EAknEditorUpperCase)  
       
 11744                 {
       
 11745                 newState = EIndicatorStateHindiPhoneticUpper;   
       
 11746                 }
       
 11747             else
       
 11748                 {
       
 11749                 newState = EIndicatorStateHindiPhoneticLower;   
       
 11750                 }
       
 11751         break;
       
 11752         default:
       
 11753         break;
       
 11754         }
       
 11755     return newState;        
       
 11756     }
       
 11757 #endif
       
 11758 TBool CAknFepManager::TryChangeModeL(TInt aMode)
       
 11759     {
       
 11760     CAknEdwinState* editorState = EditorState();
       
 11761     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 11762 
       
 11763     if (aMode == EStroke && iQwertyInputMode && sharedDataMode == ECangJie)
       
 11764     	{
       
 11765     	iEditorStateStrokeUsed = editorState;
       
 11766     	iStrokeUsedInQWERTY = ETrue;
       
 11767     	}
       
 11768     else if (iEditorStateStrokeUsed == editorState)
       
 11769     	{
       
 11770     	iStrokeUsedInQWERTY = EFalse;
       
 11771     	}
       
 11772     
       
 11773     if (aMode == ECangJie && !iQwertyInputMode && 
       
 11774     		(iFepPluginManager->PluginInputMode() != EPluginInputModeVkb
       
 11775 			|| iFepPluginManager->PluginInputMode() != EPluginInputModeFSQ))
       
 11776         {
       
 11777         aMode = EStroke;
       
 11778         }
       
 11779     
       
 11780     if (aMode == ELatinText ||aMode == ELatinUpper || aMode == ELatinLower)
       
 11781         {
       
 11782         if (TryChangeModeL(ELatin))
       
 11783             {
       
 11784             if ( !(iAknEditorFlags & EAknEditorFlagFixedCase) )
       
 11785                 {
       
 11786                 if (aMode == ELatinText)
       
 11787                     {
       
 11788                     ClearFlag(EFlagSupressAutoUpdate);
       
 11789                     }
       
 11790                 else if (aMode == ELatinUpper)
       
 11791                     {
       
 11792                     //Modify for allow text case after entering a dot and space
       
 11793                     ClearFlag(EFlagSupressAutoUpdate);
       
 11794                     //Modify for allow text case after entering a dot and space
       
 11795                     iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
 11796                     }
       
 11797                 else //lower
       
 11798                     {
       
 11799                     //Modify for allow text case after entering a dot and space
       
 11800                     ClearFlag(EFlagSupressAutoUpdate);
       
 11801                     //Modify for allow text case after entering a dot and space
       
 11802                     iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
 11803                     }
       
 11804                 UpdateIndicators();
       
 11805                 }
       
 11806             return ETrue;
       
 11807             }
       
 11808         return EFalse;
       
 11809         }
       
 11810 
       
 11811     if ( iQwertyInputMode && ( aMode == ENumber || aMode == ENativeNumber ) && 
       
 11812          !IsOnlyNumericPermitted() 
       
 11813          // Add this condition to exclude all touch inputmethods. 
       
 11814          // When change to number range on touch inputmethods, fn key state can't be locked.          
       
 11815          && iFepPluginManager 
       
 11816          && iFepPluginManager->PluginInputMode() == EPluginInputModeNone )
       
 11817         {
       
 11818         if (TryChangeModeL(ELatin))
       
 11819             {
       
 11820 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11821             // If editor should be launched in FnLock state, because in case of QWERTY keypad
       
 11822             // Current numeric mode converted to alphanumeric mode.
       
 11823             if( iFnKeyManager )
       
 11824                 {
       
 11825                 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyLock);
       
 11826                 SetCase((TCase)EFnKeyLowerCase);
       
 11827                 }
       
 11828 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 11829             return ETrue;
       
 11830             }
       
 11831         }
       
 11832 
       
 11833     if (IsModePermitted(aMode))
       
 11834         {
       
 11835         if (aMode == ELatin)
       
 11836             {
       
 11837             if (iAknEditorFlags & EAknEditorFlagNoT9)
       
 11838                 {
       
 11839                 SetWesternPredictive(EFalse);
       
 11840                 }
       
 11841 
       
 11842             if (iAknEditorFlags & EAknEditorFlagFixedCase)
       
 11843                 {
       
 11844                 iCaseMan->ConfigureCaseStateFromEditorState();
       
 11845                 }
       
 11846             }
       
 11847 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 11848         if (!iQwertyInputMode && WesternPredictive() && iFepManState == EAknFepStateUIActive)
       
 11849 #else
       
 11850         if (WesternPredictive() && iFepManState == EAknFepStateUIActive)
       
 11851 #endif            
       
 11852             {
       
 11853             TryRemoveNoMatchesIndicatorL();
       
 11854             UpdateCbaL(NULL);
       
 11855             }
       
 11856         TryCloseUiL();
       
 11857 
       
 11858         // getting a new ui manager object corresponded in aMode.
       
 11859         MAknFepManagerInterface* fepUI = iLangMan->GetFepUI(aMode, iCharWidth, 
       
 11860                                                             IsPredictive(aMode));
       
 11861         // getting the currect language id from ptiengine.
       
 11862         MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 11863         TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 11864         // getting the supported language id in current ui manager.
       
 11865         TInt currentUiLang = fepUI->SupportLanguage(aMode);
       
 11866 
       
 11867         // changing language id both ptiengine and ui manager
       
 11868         // 1. check the currect ui manager for input mode
       
 11869         // 2. check the current ptiengine and ui manager
       
 11870         if (iCurrentFepUI != fepUI
       
 11871          || currentPtiLang != currentUiLang)
       
 11872             {
       
 11873             iCurrentFepUI = fepUI;
       
 11874             TInt err = iPtiEngine->ActivateLanguageL(currentUiLang);
       
 11875             if (err != KErrNone)
       
 11876                 {
       
 11877 #ifdef _DEBUG
       
 11878                 RDebug::Print(_L("ActivateLanguageL error return code=[%d] language id=[%d]"),
       
 11879                                 err, iLanguageCapabilities.iInputLanguageCode);
       
 11880 #endif
       
 11881                 ChangeInputLanguageL(ELangEnglish);
       
 11882                 return ETrue;
       
 11883                 }
       
 11884             }
       
 11885 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11886 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
 11887         // Change secondary input
       
 11888         iPtiEngine->SetSecondaryInputL(iSharedDataInterface->InputTextLanguageSecondary());
       
 11889 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
 11890 #endif
       
 11891 
       
 11892 //#ifndef RD_INTELLIGENT_TEXT_INPUT 
       
 11893             TBuf<50> mapData;
       
 11894             //Init Data
       
 11895             for (TInt i = 0; i < 50; i++)
       
 11896                 {
       
 11897                 mapData.Append(0);
       
 11898                 }
       
 11899 
       
 11900             //Backup original input mode
       
 11901             TPtiEngineInputMode oriMode = iPtiEngine->InputMode();
       
 11902             
       
 11903             //Change current input mode, since MappingDataForKey I/F only worked
       
 11904             //when in EPtiEngineMultitapping mode
       
 11905             iPtiEngine->SetInputMode(EPtiEngineMultitapping);
       
 11906             iPtiEngine->MappingDataForKey(EPtiKey1, mapData, iPtiEngine->Case());
       
 11907             
       
 11908             //Restore
       
 11909             iPtiEngine->SetInputMode(oriMode);
       
 11910 
       
 11911             //Get first three symbols
       
 11912 			if(mapData.Length() > 0)
       
 11913 				{
       
 11914 	        	iSymbolData.iSymbol1 = mapData[0];
       
 11915 	            
       
 11916 				if (mapData.Length() > 1)
       
 11917 	            	iSymbolData.iSymbol2 = mapData[1];
       
 11918 	        	if (mapData.Length() > 2)
       
 11919 	        		iSymbolData.iSymbol3 = mapData[2];
       
 11920 				}
       
 11921             
       
 11922             //Write data to stream
       
 11923             if (iFepPluginManager && iFepPluginManager->CurrentPluginInputFepUI())
       
 11924                 {
       
 11925                 iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
 11926                             ECmdPenInputSymbolOfHardKeyOne, reinterpret_cast<TInt>(&iSymbolData));
       
 11927                 }
       
 11928 //#endif                
       
 11929         iMode = aMode;
       
 11930         
       
 11931 #ifdef RD_SCALABLE_UI_V2 
       
 11932         if ( IsChineseInputMode( aMode ) )
       
 11933             {
       
 11934             iLastChineseInputMode = aMode;
       
 11935             }        
       
 11936 #endif // RD_SCALABLE_UI_V2
       
 11937         if(iMode == ENumber || iMode == ENativeNumber )
       
 11938             {
       
 11939 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
 11940             ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
 11941             ClearFlag(CAknFepManager::EFlagNewSharedDataInputMode);
       
 11942 #endif //  RD_INTELLIGENT_TEXT_INPUT  
       
 11943             InternalFepUI()->SetNumberModeKeyMappingL(iAknEditorNumericKeymap);
       
 11944             }
       
 11945 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 11946         InternalFepUI()->SetMode(iMode, IsPredictive(), iQwertyInputMode, KeyboardLayout());
       
 11947 #else
       
 11948         InternalFepUI()->SetMode(iMode, IsPredictive(), iQwertyInputMode);
       
 11949 #endif        
       
 11950         iHashKeyMan->SetMode(iMode, IsPredictive());
       
 11951         // ensure editor is aware of new fep mode
       
 11952         if ( IsFepAwareTextEditor() )
       
 11953             {
       
 11954             EditorState()->SetCurrentInputMode(EditorModeFromFepMode(aMode));
       
 11955             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 11956             AdjustCursorTypeForCurrentPosition();
       
 11957             }
       
 11958 
       
 11959         // when cursor is in between two words and SCT is launched and
       
 11960         // cancel key is pressed, dont move the cursor at the end of
       
 11961         // second word.     
       
 11962          if (WesternPredictive(aMode) && !iUncommittedText.Length()
       
 11963             && CursorInsideWord() && !IsCcpuFlagSet(ECcpuStateSupressCursorMoveToEnd)
       
 11964 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 11965             && (!iSupressCursorMoveToEndChrKeyPressed)
       
 11966 #endif //RD_INTELLIGENT_TEXT_INPUT       
       
 11967             )
       
 11968             {
       
 11969             MoveCursorToEndOfWordL();
       
 11970             }
       
 11971         else
       
 11972             {
       
 11973 #ifdef RD_INTELLIGENT_TEXT_INPUT              
       
 11974             iSupressCursorMoveToEndChrKeyPressed = EFalse;
       
 11975 #endif //RD_INTELLIGENT_TEXT_INPUT             
       
 11976             ClearCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
 11977             }
       
 11978 
       
 11979 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11980         // Ensure that autocompletion state is updated
       
 11981         if (WesternPredictive())
       
 11982         	{
       
 11983         	SetAutoCompletionState(iSharedDataInterface->PredictiveTextAutoCompleteOn());
       
 11984         	}
       
 11985 #endif
       
 11986         // Set multitap timer to PtiEngine for Japanese variant only
       
 11987         if (IsFeatureSupportedJapanese())
       
 11988             {
       
 11989             TInt timeout = (iInputCapabilities.SupportsSecretText())? 
       
 11990             					KSyncPasswdTimeout : iMultiTapTimer;
       
 11991             iPtiEngine->HandleCommandL(EPtiCommandSetMultitapTimer, &timeout);
       
 11992             iPtiEngine->HandleCommandL(EPtiCommandSetJapaneseQwertyFlags, &iJapaneseQwertyFlags);
       
 11993             TInt clear = iSharedDataInterface->ClearDirection();
       
 11994             iPtiEngine->HandleCommandL(EPtiCommandSetClearFunction, &clear);
       
 11995             // Send PtiEngine the command whether Pictograph is allowed in Candidate list
       
 11996             TInt allow = IsAbleToLaunchPCT();
       
 11997 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 11998             iPtiEngine->HandleCommandL(EPtiCommandAllowPictographCandidate, &allow);
       
 11999 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 12000             }
       
 12001 
       
 12002         UpdateIndicators(); // moved to bottom to avoid extra indicator updates
       
 12003 
       
 12004         return ETrue;
       
 12005         }
       
 12006     return EFalse;
       
 12007     }
       
 12008 
       
 12009 void CAknFepManager::ChangeInputLanguageL(TInt aInputLanguage)
       
 12010     {
       
 12011     	if(iLangMan)
       
 12012     	{
       
 12013     	iLangMan->SetInputLanguageL(aInputLanguage);
       
 12014 
       
 12015     	SetInputLanguageCapabilities(aInputLanguage);
       
 12016 
       
 12017     	ReadHashKeyLoopL();
       
 12018 		// we need to make sure that we commit the word to ptiengine, 
       
 12019 		// so that the word gets added to the UWD 
       
 12020     	SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
 12021     	// Addition for ITI on FSQ
       
 12022     	// When FSQ is opened with the ITI-supported input language, 
       
 12023     	// if switch to another language which doesn't support ITI, such as Korean,
       
 12024     	// need to restore the previous configuration on FEP
       
 12025         if ( iFepPluginManager )
       
 12026         	{    	
       
 12027         	iFepPluginManager->ResetItiStateL();
       
 12028         	}    	
       
 12029     	if ( !TryChangeModeL(NewInputModeAfterLanguageChange()) )
       
 12030 	        {
       
 12031 	        if ( !TryChangeModeL(ELatin) )
       
 12032 	            {
       
 12033 	            // If the editor does not support text input mode, we try number mode.
       
 12034 	            if( IsInputModeAvailable(ENativeNumber) && 
       
 12035 	                ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 12036 	                  iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 12037 	                  iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 12038 	                {
       
 12039 	                TryChangeModeL(ENativeNumber);;
       
 12040 	                }
       
 12041 	            else
       
 12042 	                {
       
 12043 	                TryChangeModeL(ENumber);
       
 12044 	                }
       
 12045 	            }
       
 12046 	        }
       
 12047   
       
 12048         if (!iLanguageCapabilities.iLocalInputLanguageInUse)
       
 12049         	{
       
 12050         	switch (iSharedDataInterface->InputTextLanguage())
       
 12051             	{
       
 12052             	case ELangPrcChinese:
       
 12053             		{
       
 12054             		iSharedDataInterface->SetInputMode(EPinyin);
       
 12055             		SetFlag(EFlagNewSharedDataInputMode);
       
 12056             		break;            		
       
 12057             		}
       
 12058             	case ELangTaiwanChinese:
       
 12059             		{
       
 12060             	    iSharedDataInterface->SetInputMode(EZhuyin);
       
 12061             	    SetFlag(EFlagNewSharedDataInputMode);
       
 12062             	    break;
       
 12063             		}
       
 12064             	case ELangHongKongChinese:
       
 12065             		{
       
 12066             	    iSharedDataInterface->SetInputMode(EStroke);
       
 12067             	    iSharedDataInterface->SetCangJieMode(ECangJieNormal);
       
 12068             	    SetFlag(EFlagNewSharedDataInputMode);
       
 12069             	    break;
       
 12070             		}
       
 12071             	default:
       
 12072             		break;
       
 12073             	}
       
 12074             }
       
 12075 
       
 12076     	SetHashKeyStyle();
       
 12077     	UpdateEditorContext();
       
 12078   		}
       
 12079     //add notify to phrase creation udbmanagement view
       
 12080     
       
 12081     if(iUserdbdlg)
       
 12082 	    {
       
 12083 	    iUserdbdlg->OnChangeLanguageL( aInputLanguage );	
       
 12084 	    if ( aInputLanguage != ELangPrcChinese &&
       
 12085 	        	 aInputLanguage != ELangTaiwanChinese &&
       
 12086 	        	 aInputLanguage != ELangHongKongChinese )
       
 12087 	    	{
       
 12088 	    	iUserdbdlg = NULL;
       
 12089 	    	}
       
 12090 	    }
       
 12091     }
       
 12092 
       
 12093 void CAknFepManager::RemovePreviousCharacterL()
       
 12094     {
       
 12095     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 12096         {
       
 12097         CommitInlineEditL();
       
 12098         }
       
 12099 
       
 12100     // Set cursor span on previous character
       
 12101     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 12102     if (iUncommittedText.iAnchorPos > 0)
       
 12103         {
       
 12104         iUncommittedText.iAnchorPos--;
       
 12105         }
       
 12106     
       
 12107 
       
 12108     // get text to replace
       
 12109     TBuf<ESingleCharacter> charToReplace;
       
 12110     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(charToReplace, 
       
 12111                                                                     iUncommittedText.iAnchorPos, 
       
 12112                                                                     ESingleCharacter);
       
 12113 
       
 12114     // delete the character with an inline edit
       
 12115     StartInlineEditL(iUncommittedText, charToReplace, ESingleCharacter, EFalse);
       
 12116     UpdateInlineEditL(KNullDesC, 0);
       
 12117     CommitInlineEditL();
       
 12118     }
       
 12119 
       
 12120 void CAknFepManager::RemoveZWSCharacterL( TBool aIsViramaInputted, 
       
 12121                                             TBool aIsInMultitappingHalant, 
       
 12122                                             TBool aIsCharModifier, 
       
 12123                                             TBool aIsLigaturePresent /*= EFalse*/)
       
 12124     {
       
 12125     CTextLayout* textLayout = TextLayout();
       
 12126     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 12127     if(!textLayout && !docNavi)
       
 12128         return;
       
 12129 
       
 12130     if( aIsLigaturePresent )
       
 12131         {
       
 12132         TTmDocPosSpec pos = DocPos();
       
 12133         TTmPosInfo2 info;
       
 12134         TTmLineInfo lineInfo;
       
 12135         if (docNavi)
       
 12136         	{
       
 12137         	docNavi->FindDocPos(pos, info, lineInfo);
       
 12138         	}
       
 12139         else
       
 12140         	{
       
 12141         	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);      
       
 12142         	}
       
 12143 
       
 12144         if( IsZWSCharacterPresent( ETrue ) )
       
 12145             {
       
 12146             TInt commitPoint = pos.iPos - 2;
       
 12147             if( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
 12148                 {
       
 12149                 CommitInlineEditL();
       
 12150                 }
       
 12151 
       
 12152             TCursorSelection sel( commitPoint, commitPoint );
       
 12153             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 12154             }
       
 12155         }
       
 12156     else
       
 12157         {
       
 12158         if ( IsFlagSet(EFlagInsideInlineEditingTransaction) && IsZWSCharacterPresent())
       
 12159             {
       
 12160             CommitInlineEditL();
       
 12161             }
       
 12162         }
       
 12163 
       
 12164     TTmDocPosSpec pos = DocPos();
       
 12165     pos.iType = TTmDocPosSpec::ETrailing;
       
 12166     TTmPosInfo2 info;
       
 12167     TTmLineInfo lineInfo;
       
 12168     if ( ! iInputCapabilities.SupportsSecretText() )
       
 12169         {
       
 12170         if (docNavi)
       
 12171         	{
       
 12172         	docNavi->FindDocPos(pos, info, lineInfo);
       
 12173         	}
       
 12174         else
       
 12175         	{
       
 12176         	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);
       
 12177         	}
       
 12178         TBuf<2> previousCharacter;
       
 12179         TBuf<1> zwsPrevChar;
       
 12180         previousCharacter.FillZ();
       
 12181         zwsPrevChar.FillZ();
       
 12182         TBool found = EFalse;
       
 12183 
       
 12184         TCursorSelection curSel;
       
 12185         if ( IsFepAwareTextEditor() )
       
 12186             {
       
 12187             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 12188             TInt lowerpos = curSel.LowerPos();
       
 12189             if( lowerpos > 0)
       
 12190                 {
       
 12191                 if(lowerpos > 1)
       
 12192                 iInputCapabilities.FepAwareTextEditor()->
       
 12193                     GetEditorContentForFep(previousCharacter, lowerpos - 2, 2);
       
 12194                 else
       
 12195                 iInputCapabilities.FepAwareTextEditor()->
       
 12196                     GetEditorContentForFep(previousCharacter, lowerpos - 1, 1);
       
 12197                     
       
 12198                 if( lowerpos > 1 )
       
 12199                     {
       
 12200                     if(previousCharacter[1] == ZERO_WIDTH_SPACE)
       
 12201                         {
       
 12202                         zwsPrevChar.Append(previousCharacter[1]);
       
 12203                         if( aIsInMultitappingHalant )
       
 12204                             {
       
 12205                             curSel.iAnchorPos = lowerpos - 2;
       
 12206                             }
       
 12207                         else
       
 12208                             {
       
 12209                             curSel.iAnchorPos = lowerpos - 1;
       
 12210                             }
       
 12211                         found = ETrue;      
       
 12212                         }
       
 12213                     else if( previousCharacter[0] == ZERO_WIDTH_SPACE )
       
 12214                         {
       
 12215                         zwsPrevChar.Append(previousCharacter[0]);
       
 12216                         curSel.iAnchorPos = lowerpos - 2;
       
 12217                         curSel.iCursorPos = lowerpos - 1;                       
       
 12218                         found = ETrue;
       
 12219                         }   
       
 12220                     }
       
 12221                 else
       
 12222                     {
       
 12223                     if(previousCharacter[0] == ZERO_WIDTH_SPACE)
       
 12224                         {
       
 12225                         zwsPrevChar.Append(previousCharacter[0]);
       
 12226                         if( aIsInMultitappingHalant )
       
 12227                             {
       
 12228                             curSel.iAnchorPos = lowerpos - 2;
       
 12229                             }
       
 12230                         else
       
 12231                             {
       
 12232                             curSel.iAnchorPos = lowerpos - 1;
       
 12233                             }
       
 12234                         found = ETrue;    
       
 12235                         }   
       
 12236                     }    
       
 12237                 
       
 12238                 }
       
 12239             }
       
 12240         if( found )
       
 12241             {
       
 12242             StartInlineEditL(curSel, zwsPrevChar, ESingleCharacter, ETrue);
       
 12243             UpdateInlineEditL(KNullDesC, 0);
       
 12244             CommitInlineEditL();    
       
 12245             if ( !aIsInMultitappingHalant && ! iInputCapabilities.SupportsSecretText() )
       
 12246                 {
       
 12247                 if ( aIsViramaInputted )
       
 12248                     {
       
 12249                     TTmDocPosSpec pos = DocPos();
       
 12250                     TTmPosInfo2 infotemp;
       
 12251                     if (docNavi)
       
 12252                     	{
       
 12253                     	docNavi->FindDocPos(pos, info, lineInfo);      
       
 12254                     	}
       
 12255                     else
       
 12256                     	{
       
 12257                     	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);      
       
 12258                     	}
       
 12259                     if(NextChar() && TAknFepUiIndicInputManager::IsCharBaseConsonant(NextChar(), 
       
 12260                                            TLanguage(iLanguageCapabilities.iInputLanguageCode)))
       
 12261 	                    {
       
 12262 	                    TInt nextPos;                  
       
 12263 	                    if (docNavi)
       
 12264 	                    	{
       
 12265 	                    	nextPos = docNavi->FindNextPos(pos.iPos);
       
 12266 	                    	}
       
 12267 	                    else
       
 12268 	                    	{
       
 12269 		                    nextPos = textLayout->TagmaTextLayout().FindNextPos(pos.iPos);                 
       
 12270 	                    	}
       
 12271 	                    info.iDocPos.iPos  = nextPos;   
       
 12272 	                    }
       
 12273                     else if((TAknFepUiIndicInputManager::IsCharAnVowel(NextChar(), 
       
 12274                              TLanguage(iLanguageCapabilities.iInputLanguageCode)))
       
 12275                          &&(aIsCharModifier && TAknFepUiIndicInputManager::IsCharVirama(
       
 12276                              PreviousChar(), TLanguage(iLanguageCapabilities.iInputLanguageCode))))
       
 12277                         {
       
 12278                         bool posFound;
       
 12279 		                if (docNavi)
       
 12280 		                	{
       
 12281 		                	posFound = docNavi->GetNextVisualCursorPos(pos, infotemp, EFalse);      
       
 12282 		                	}
       
 12283 		                else
       
 12284 		                	{
       
 12285 		                	posFound = textLayout->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 12286                                                                                       infotemp, 
       
 12287                                                                                       EFalse);      
       
 12288 		                	}
       
 12289                         
       
 12290                     	if (posFound)
       
 12291                             {
       
 12292                             info.iDocPos.iPos = infotemp.iDocPos.iPos;
       
 12293                             }
       
 12294                         }
       
 12295                     TCursorSelection sel(info.iDocPos.iPos ,info.iDocPos.iPos );
       
 12296                     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);    
       
 12297                     }
       
 12298                 else
       
 12299                     {
       
 12300                     TCursorSelection sel(info.iDocPos.iPos - 1,info.iDocPos.iPos - 1);
       
 12301                     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);        
       
 12302                     }   
       
 12303                 
       
 12304                 SendEventsToPluginManL( EPluginSyncFepAwareText );
       
 12305                 }
       
 12306             }
       
 12307         }
       
 12308     }
       
 12309 
       
 12310 void  CAknFepManager::TryChangePredictiveInputModeL(TBool aFlag)
       
 12311     {
       
 12312     if(Japanese() && iMode != ELatin)
       
 12313         {
       
 12314         if(aFlag)
       
 12315             {
       
 12316             if (!(iAknEditorFlags & EAknEditorFlagNoT9)
       
 12317                && HasJapanesePredictionInputMode())
       
 12318                 {
       
 12319                 iJapanesePredictive = aFlag;
       
 12320                 iSharedDataInterface->SetJapanesePredictiveTextOn();
       
 12321                 }
       
 12322             }
       
 12323         else
       
 12324             {
       
 12325             iJapanesePredictive = aFlag;
       
 12326             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 12327             }
       
 12328         }
       
 12329     else
       
 12330         {
       
 12331         SetWesternPredictive(aFlag);
       
 12332         }
       
 12333     TryChangeModeL(iMode);
       
 12334     }
       
 12335 
       
 12336 MCoeFepAwareTextEditor* CAknFepManager::FepAwareTextEditor() const
       
 12337     {
       
 12338     return iInputCapabilities.FepAwareTextEditor();
       
 12339     }
       
 12340 
       
 12341 TBool CAknFepManager::IsFepAwareTextEditor() const
       
 12342     {
       
 12343 #ifdef RD_SCALABLE_UI_V2   
       
 12344     return FullyFepAwareTextEditor();
       
 12345 #else
       
 12346 		return ( iInputCapabilities.FepAwareTextEditor() ? ETrue : EFalse );
       
 12347 #endif    
       
 12348     }
       
 12349     
       
 12350 TCursorSelection CAknFepManager::UncommittedText() const
       
 12351     {
       
 12352     return iUncommittedText;
       
 12353     }
       
 12354 
       
 12355 void CAknFepManager::SetCase(TCase aCase)
       
 12356     {
       
 12357     // For QWERTY only keypad, extended input state like FnLock is applicable.
       
 12358     // In case of ITU-T keypad, this flag should not be part of editor flag.
       
 12359     // In case of numeric only editor Only FnReverse state is valid and editor will be on EFnReverse
       
 12360     // State if FnKey is hold on state.
       
 12361     
       
 12362     //TODO: In case of other functionized input state like (FnNext), it should be stored in editor
       
 12363     
       
 12364 #ifdef  RD_INTELLIGENT_TEXT_INPUT
       
 12365     if(EditorState())
       
 12366         {
       
 12367         if( iFnKeyManager &&  ( iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyLock ) )
       
 12368             {
       
 12369             EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagFnLock );
       
 12370             }
       
 12371         else
       
 12372             {
       
 12373             EditorState()->SetFlags( EditorState()->Flags() & ~EAknEditorFlagFnLock );       
       
 12374             }
       
 12375         }
       
 12376 #endif
       
 12377 
       
 12378     InternalFepUI()->SetCase(aCase);
       
 12379     }
       
 12380 
       
 12381 CAknEdwinState* CAknFepManager::EditorState() const
       
 12382     {
       
 12383     if ( IsFepAwareTextEditor() )
       
 12384         {
       
 12385         MCoeFepAwareTextEditor* fepAvareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 12386         
       
 12387         if ( fepAvareTextEditor && fepAvareTextEditor->Extension1() )
       
 12388             {
       
 12389             return static_cast<CAknEdwinState*>( fepAvareTextEditor->Extension1()->State( KNullUid ) );
       
 12390             }
       
 12391         }
       
 12392     return NULL;
       
 12393     }
       
 12394 
       
 12395  void CAknFepManager::SetPredictiveIndicatorState(TAknEditingState& aState)
       
 12396 	{
       
 12397 	
       
 12398 	TInt currentCase = iCaseMan->CurrentCase();
       
 12399 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 12400     if(iIsAutoCompleteOn && iLanguageCapabilities.iInputLanguageCode != ELangThai)
       
 12401     	{
       
 12402        	if (iLanguageCapabilities.iInputLanguageCode == ELangArabic)
       
 12403         	aState=EAutoCompleteArabic;
       
 12404        	
       
 12405        	else if (iLanguageCapabilities.iInputLanguageCode == ELangHebrew)
       
 12406            		 aState=EAutoCompleteHebrew;
       
 12407        	
       
 12408         else if (iLanguageCapabilities.iInputLanguageCode == ELangFarsi ||
       
 12409             	 iLanguageCapabilities.iInputLanguageCode == ELangUrdu)
       
 12410             	 aState=EAutoCompleteFarsiAndUrdu;
       
 12411              	/*Hindi*/
       
 12412         else if ( (iLanguageCapabilities.iInputLanguageCode == ELangHindi) || (iLanguageCapabilities.iInputLanguageCode == ELangMarathi))
       
 12413         		  aState = EAutoCompleteHindi;
       
 12414         
       
 12415         else if(iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 12416             	{
       
 12417             	switch (currentCase)
       
 12418                 	{
       
 12419                 	case EAknEditorUpperCase:
       
 12420                     	aState =  EAutoCompleteUpperVietnamese;
       
 12421                     	break;
       
 12422                 	case EAknEditorLowerCase:
       
 12423                     	aState =  EAutoCompleteLowerVietnamese;
       
 12424                     	break;
       
 12425                     case EAknEditorTextCase:
       
 12426                         aState = EAutoCompleteShiftedVietnamese;
       
 12427                         break;
       
 12428                     default:
       
 12429                         break;
       
 12430                     }    
       
 12431                 }
       
 12432         else
       
 12433                 {
       
 12434                 switch (currentCase)
       
 12435                     {
       
 12436                     case EAknEditorUpperCase:
       
 12437                         aState =  EAutoCompleteUpper;
       
 12438                         break;
       
 12439                     case EAknEditorLowerCase:
       
 12440                         aState =  EAutoCompleteLower;
       
 12441                         break;
       
 12442                     case EAknEditorTextCase:
       
 12443                         aState = EAutoCompleteShifted;
       
 12444                         break;
       
 12445                     default:
       
 12446                         break;
       
 12447                     }
       
 12448                 }
       
 12449             
       
 12450     	}
       
 12451     else
       
 12452 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 12453 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12454 		if(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
 12455 			{
       
 12456 			aState = EFnKeyPressed;
       
 12457 			if(iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyLock)
       
 12458 	            aState = EFnKeyLocked;    
       
 12459 			}
       
 12460         else
       
 12461 #endif
       
 12462         {
       
 12463     	if (iLanguageCapabilities.iInputLanguageCode == ELangArabic)
       
 12464       	 	 aState = ET9Arabic;
       
 12465     	
       
 12466    		else if (iLanguageCapabilities.iInputLanguageCode == ELangHebrew)
       
 12467         	     aState = ET9Hebrew;
       
 12468    		
       
 12469     	else if (iLanguageCapabilities.iInputLanguageCode == ELangFarsi ||
       
 12470         	     iLanguageCapabilities.iInputLanguageCode == ELangUrdu)
       
 12471         		 aState = ET9FarsiAndUrdu;
       
 12472         		 
       
 12473     	else if (iLanguageCapabilities.iInputLanguageCode == ELangThai)
       
 12474         		 aState = ET9Thai;
       
 12475     	
       
 12476     	/*Hindi*/
       
 12477 #ifdef RD_MARATHI
       
 12478                         /*Marathi*/
       
 12479                         else if ( iLanguageCapabilities.iInputLanguageCode == ELangMarathi )
       
 12480                         	aState = EIndicatorStatePredictiveMarathi;
       
 12481 #endif // RD_MARATHI
       
 12482     	
       
 12483     	else if(iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 12484         	{
       
 12485         	switch (currentCase)
       
 12486             	{
       
 12487             	case EAknEditorUpperCase:
       
 12488                 	aState =  ET9UpperVietnamese;
       
 12489                 	break;
       
 12490             	case EAknEditorLowerCase:
       
 12491                 	aState =  ET9LowerVietnamese;
       
 12492                 	break;
       
 12493                 case EAknEditorTextCase:
       
 12494                     aState = ET9ShiftedVietnamese;
       
 12495                     break;
       
 12496                 default:
       
 12497                     break;
       
 12498                 }    
       
 12499             }
       
 12500         
       
 12501         else if(iLanguageCapabilities.iInputLanguageCode == ELangGreek)
       
 12502             {
       
 12503             switch (currentCase)
       
 12504                 {
       
 12505                 case EAknEditorUpperCase:
       
 12506                     aState =  ET9UpperGreek;
       
 12507                     break;
       
 12508                 case EAknEditorLowerCase:
       
 12509                     aState =  ET9LowerGreek;
       
 12510                     break;
       
 12511                 case EAknEditorTextCase:
       
 12512                     aState = ET9ShiftedGreek;
       
 12513                     break;
       
 12514                 default:
       
 12515                     break;
       
 12516                 }    
       
 12517             }
       
 12518         
       
 12519         //Cyrillic alphabet is used for Russian, Bulgarian and 
       
 12520         //Ukranian languages
       
 12521         else if(iLanguageCapabilities.iInputLanguageCode == ELangRussian ||
       
 12522                 iLanguageCapabilities.iInputLanguageCode == ELangBulgarian ||
       
 12523                 iLanguageCapabilities.iInputLanguageCode == ELangUkrainian )
       
 12524             {
       
 12525             switch (currentCase)
       
 12526                 {
       
 12527                 case EAknEditorUpperCase:
       
 12528                     aState =  ET9UpperCyrillic;
       
 12529                     break;
       
 12530                 case EAknEditorLowerCase:
       
 12531                     aState =  ET9LowerCyrillic;
       
 12532                     break;
       
 12533                 case EAknEditorTextCase:
       
 12534                     aState = ET9ShiftedCyrillic;
       
 12535                     break;
       
 12536                 default:
       
 12537                     break;
       
 12538                 }    
       
 12539             }
       
 12540         else
       
 12541             {
       
 12542             switch (currentCase)
       
 12543                 {
       
 12544                 case EAknEditorUpperCase:
       
 12545                     aState = ET9Upper;
       
 12546                     break;
       
 12547                 case EAknEditorLowerCase:
       
 12548                     aState = ET9Lower;
       
 12549                     break;
       
 12550                 case EAknEditorTextCase:
       
 12551                     aState = ET9Shifted;
       
 12552                     break;
       
 12553                 default:
       
 12554                     break;
       
 12555                 }
       
 12556             }
       
 12557         
       
 12558     	}
       
 12559 	}
       
 12560 void CAknFepManager::UpdateIndicators()
       
 12561     { 
       
 12562     if(ELongKeyPress == iKeyRepeat)
       
 12563         return;	
       
 12564 	// If it is fepware editor update the Indicators
       
 12565 	// otherwise not need excute remainig part of code.
       
 12566 	if( !iInputCapabilities.FepAwareTextEditor() || !iFepFullyConstructed ) 
       
 12567 		{
       
 12568         //Ensure, If no idicator is require, make indicator state None 
       
 12569         if (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible))
       
 12570             iIndicator->SetState(EStateNone);
       
 12571 		return;
       
 12572 		}
       
 12573 
       
 12574     TAknEditingState newState = EStateNone;
       
 12575     MPtiLanguage* ptiLang = PtiEngine()->CurrentLanguage();    
       
 12576     MAknEditingStateIndicator* editingStateIndicator = EditingStateIndicator();
       
 12577 
       
 12578     TBool findPaneIndicator(
       
 12579         iAknEditorFlags & EAknEditorFlagNoEditIndicators &&
       
 12580         iAknEditorFlags & EAknEditorFlagForceTransparentFepModes &&
       
 12581         editingStateIndicator != (MAknEditingStateIndicator*)iIndicator );
       
 12582 
       
 12583 #ifdef RD_SCALABLE_UI_V2
       
 12584     TBool fingerItutIndicator = ( iFepPluginManager && 
       
 12585                                   iFepPluginManager->PluginInputMode() == EPluginInputModeItut );
       
 12586 #else
       
 12587     TBool fingerItutIndicator = EFalse;
       
 12588     
       
 12589 #endif
       
 12590     if ( IsHybridAplhaEditor() && !iHybridAplphaChangedToAlphanumeric )
       
 12591             {
       
 12592             newState = EHybridModeLatin;
       
 12593             }    
       
 12594     else if (!(iAknEditorFlags & EAknEditorFlagNoEditIndicators) 
       
 12595         || findPaneIndicator || fingerItutIndicator)
       
 12596         {
       
 12597         
       
 12598 #ifdef RD_SCALABLE_UI_V2
       
 12599         if ( ( IsFlagSet(EFlagQwertyShiftMode)  || IsFlagSet(EFlagLongShiftKeyPress)) &&
       
 12600              ((iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeVkb) ||
       
 12601         #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 12602 			      iQwertyInputMode
       
 12603       	#else	       								
       
 12604 		           ( iQwertyInputMode && (IsFlagSet(EFlagQwertyShiftMode) ||IsFlagSet(EFlagLongShiftKeyPress))
       
 12605 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext)
       
 12606 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
 12607 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
 12608 		           )
       
 12609 		#endif
       
 12610              ))
       
 12611 #else
       
 12612         if ( iQwertyInputMode && IsFlagSet(EFlagQwertyShiftMode))
       
 12613     
       
 12614 #endif        
       
 12615             {
       
 12616             newState = EQwertyShift;
       
 12617 
       
 12618 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
 12619 			// To keep the shift key indicator in         
       
 12620             // Check if fn/shift both key are pressed 
       
 12621             if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone) &&
       
 12622             	(IsFlagSet(EFlagQwertyShiftMode) || IsFlagSet(EFlagLongShiftKeyPress)))
       
 12623 	            {
       
 12624 	            newState = EFnKeyPressed;	
       
 12625 	            }
       
 12626 #endif            
       
 12627             
       
 12628             }
       
 12629         else
       
 12630             {
       
 12631             switch (iMode)
       
 12632                 {
       
 12633                 case EHiraganaKanji:
       
 12634                     if (IsPredictive())
       
 12635                         {
       
 12636                         newState = EIndicatorStateJapanesePredictive;
       
 12637                         }
       
 12638                     else
       
 12639                         {
       
 12640                         newState = EIndicatorStateHiraganaKanji;
       
 12641                         }
       
 12642                     break;
       
 12643                 case EKatakana:
       
 12644                     if (iCharWidth == EHalfWidthChar)
       
 12645                         {
       
 12646                         newState = EIndicatorStateHalfKatakana;
       
 12647                         }
       
 12648                     else if (iCharWidth == EFullWidthChar)
       
 12649                         {
       
 12650                         newState = EIndicatorStateFullKatakana;
       
 12651                         }
       
 12652                     break;
       
 12653                 case EHiragana:
       
 12654                     {
       
 12655                     newState = EIndicatorStateHiragana;
       
 12656                     }
       
 12657                     break;
       
 12658                 case EPinyin:
       
 12659                     if (ptiLang->HasInputMode(EPtiEnginePinyinByPhrase))
       
 12660                         {
       
 12661                         newState = EIndicatorStatePinyinPhrase;
       
 12662                         }                        
       
 12663                     else
       
 12664                         {
       
 12665                         newState = EIndicatorStatePinyin;
       
 12666                         }                        
       
 12667 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12668                     if ( iFnKeyManager->FnKeyState()
       
 12669                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12670                         newState = EFnKeyLocked;
       
 12671                     else if ( iFnKeyManager->FnKeyState()
       
 12672                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12673                         newState = EFnKeyPressed;
       
 12674 #endif
       
 12675                     break;
       
 12676                 case EZhuyin:
       
 12677                     if (ptiLang->HasInputMode(EPtiEngineZhuyinByPhrase))
       
 12678                         {
       
 12679                         newState = EIndicatorStateZhuyinPhrase;
       
 12680                         }                        
       
 12681                     else
       
 12682                         {
       
 12683                         newState = EIndicatorStateZhuyin;
       
 12684                         }                        
       
 12685 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12686                     if ( iFnKeyManager->FnKeyState()
       
 12687                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12688                         newState = EFnKeyLocked;
       
 12689                     else if ( iFnKeyManager->FnKeyState()
       
 12690                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12691                         newState = EFnKeyPressed;
       
 12692 #endif
       
 12693                     break;
       
 12694                 case EStroke:
       
 12695                     {
       
 12696                     TBool flag = ptiLang->HasInputMode(EPtiEngineStrokeByPhrase);
       
 12697                     if (iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
 12698                         {
       
 12699                         if (flag)
       
 12700                             {
       
 12701                             newState = EIndicatorStateStrokePhrase;
       
 12702                             }                            
       
 12703                         else
       
 12704                             {
       
 12705                             newState = EIndicatorStateStroke;
       
 12706                             }                            
       
 12707                         }
       
 12708                     else
       
 12709                         {
       
 12710                         if (flag)
       
 12711                             {
       
 12712                             newState = EIndicatorStateStrokeTradPhrase;
       
 12713                             }                            
       
 12714                         else
       
 12715                             {
       
 12716                             newState = EIndicatorStateStrokeTrad;
       
 12717                             }                            
       
 12718                         }
       
 12719                         }
       
 12720 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12721                     if ( iFnKeyManager->FnKeyState()
       
 12722                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12723                         newState = EFnKeyLocked;
       
 12724                     else if ( iFnKeyManager->FnKeyState()
       
 12725                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12726                         newState = EFnKeyPressed;
       
 12727 #endif
       
 12728                     break;
       
 12729                 case ECangJie:
       
 12730                     newState = EIndicatorStateCangJie;
       
 12731 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12732                     if ( iFnKeyManager->FnKeyState()
       
 12733                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12734                         newState = EFnKeyLocked;
       
 12735                     else if ( iFnKeyManager->FnKeyState()
       
 12736                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12737                         newState = EFnKeyPressed;
       
 12738 #endif
       
 12739                     break;
       
 12740                 case EZhuyinFind:
       
 12741                     newState = EIndicatorStateZhuyinFind;
       
 12742                     break;
       
 12743                 case EStrokeFind:
       
 12744                     newState = EIndicatorStateStrokeFind;
       
 12745                     break;
       
 12746                 case ENumber:
       
 12747                     {
       
 12748                     newState = ENumeric;
       
 12749                     //iLanguageCapabilities.iLocalDigitType = EDigitTypeWestern;
       
 12750                     }
       
 12751                     break;
       
 12752                 case ENativeNumber:
       
 12753                     {
       
 12754                     UpdateNumberIndicator( newState );
       
 12755                     }
       
 12756                     break;
       
 12757                 case EHangul:
       
 12758                 	{
       
 12759                 	newState = EIndicatorStateHangul;            	              	
       
 12760                 	}
       
 12761                 	break;
       
 12762                 case ELatin:
       
 12763                     {
       
 12764                     UpdateLatinIndicator( newState );
       
 12765                     }
       
 12766                     break;
       
 12767                 case EHindi:
       
 12768                     {
       
 12769                     UpdateHindiIndicator( newState );
       
 12770                     }
       
 12771                     break;
       
 12772                 default:
       
 12773                     break;
       
 12774            }
       
 12775         }
       
 12776     }
       
 12777 
       
 12778     if ( iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeVkb )
       
 12779         {
       
 12780         newState = iFepPluginManager->VKBIndicatorState( newState );
       
 12781         }
       
 12782 
       
 12783     // Update indicators only if the state has been changed, or if the indicator has swapped
       
 12784     if ((iPreviousEditingState != newState) || (editingStateIndicator != iEditIndicatorAtLastUpdate))
       
 12785         {
       
 12786         if (editingStateIndicator)
       
 12787             {
       
 12788             // because current avkon have not find chinese phrase indicator,
       
 12789             // so change back to no-phrase
       
 12790            if (findPaneIndicator || iAknEditorFlags & EAknEditorFlagFindPane )
       
 12791                 {
       
 12792                 switch(newState)
       
 12793                     {
       
 12794                     case EIndicatorStateStrokePhrase:
       
 12795                         {
       
 12796                         newState = EIndicatorStateStroke; 
       
 12797                         }
       
 12798                     break;
       
 12799                     case EIndicatorStateStrokeTradPhrase:
       
 12800                         {
       
 12801                         newState = EIndicatorStateStrokeTrad; 
       
 12802                         }
       
 12803                     break;
       
 12804                     case EIndicatorStatePinyinPhrase:
       
 12805                         {
       
 12806                         newState = EIndicatorStatePinyin; 
       
 12807                         }
       
 12808                     break;
       
 12809                     case EIndicatorStateZhuyinPhrase:
       
 12810                         {
       
 12811                         newState = EIndicatorStateZhuyin; 
       
 12812                         }
       
 12813                     break;
       
 12814                     default:
       
 12815                         {
       
 12816                         break;
       
 12817                         }
       
 12818                     }
       
 12819                 }
       
 12820            // Add This condition for Fixing EYYE-7HHBWW: Phonebook, ReTe, PF52.50_2008_wk32: 
       
 12821            // Navigation bar disappears after tapping find pane and then returning back to Names list view.
       
 12822            if (!(editingStateIndicator == (MAknEditingStateIndicator*)iIndicator &&
       
 12823                ( iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeItut ) &&
       
 12824                IsFindPaneEditor()))
       
 12825                {
       
 12826                editingStateIndicator->SetState(newState);
       
 12827                }
       
 12828 
       
 12829             // Ensure that no indicator is shown in navi pane when other
       
 12830             // indicator is changed in use.
       
 12831             if ( editingStateIndicator != (MAknEditingStateIndicator*)iIndicator &&
       
 12832                  iPreviousEditingState == EStateNone &&
       
 12833                  (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible)) )
       
 12834 
       
 12835                 {
       
 12836                 iIndicator->SetState( EStateNone );
       
 12837                 }
       
 12838 
       
 12839             iPreviousEditingState = newState;
       
 12840             iEditIndicatorAtLastUpdate=editingStateIndicator;
       
 12841             }
       
 12842         }
       
 12843     }
       
 12844 
       
 12845 void CAknFepManager::UpdateNumberIndicator( TAknEditingState& aNewState )
       
 12846     {
       
 12847     
       
 12848  // chnage for AIYR-6L7DGU; This problrm persist in all variants. 
       
 12849  // The fix is made only for Hindi
       
 12850     UpdateNumericEditorDigitType();
       
 12851     TBool supportsWesternNumericIntegerOrReal =
       
 12852         ( iInputCapabilities.SupportsWesternNumericIntegerPositive() ||
       
 12853         iInputCapabilities.SupportsWesternNumericIntegerNegative() ||
       
 12854         iInputCapabilities.SupportsWesternNumericReal() );
       
 12855 
       
 12856 #ifdef RD_SCALABLE_UI_V2                        
       
 12857         iFepPluginManager->SetPluginNativeRange( ETrue );
       
 12858 #endif // RD_SCALABLE_UI_V2 
       
 12859         // In usual case digit mode is Arabic-Indic digits if local digit mode is
       
 12860         // Arabic-Indic and current input language is Arabic.
       
 12861         if ( (!supportsWesternNumericIntegerOrReal &&
       
 12862             iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic /* &&
       
 12863             iLanguageCapabilities.iInputLanguageCode == ELangArabic*/
       
 12864             )
       
 12865             ||
       
 12866             // But digit mode is Arabic-Indic digit in MFNE and real number
       
 12867             // editors if UI language is Arabic and global digit setting is
       
 12868             // Arabic-Indic digits.
       
 12869             ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 12870             iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeArabicIndic && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 12871             supportsWesternNumericIntegerOrReal &&
       
 12872             iUiLanguage == ELangArabic
       
 12873             )
       
 12874             )
       
 12875             {
       
 12876             aNewState=EArabicIndicNumeric;
       
 12877                         
       
 12878             }
       
 12879         else if ( (!supportsWesternNumericIntegerOrReal &&
       
 12880             iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic /* &&
       
 12881             iLanguageCapabilities.iInputLanguageCode == ELangUrdu,Farasi*/
       
 12882             )
       
 12883             ||
       
 12884             // But digit mode is Arabic-Indic digit in MFNE and real number
       
 12885             // editors if UI language is Arabic and global digit setting is
       
 12886             // Arabic-Indic digits.
       
 12887             ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 12888             iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeEasternArabicIndic && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 12889             supportsWesternNumericIntegerOrReal &&
       
 12890             (iUiLanguage == ELangUrdu || iUiLanguage == ELangFarsi)))
       
 12891             {
       
 12892             aNewState=EArabicIndicNumeric;                            
       
 12893             }    
       
 12894         /* Devanagari Scripts */
       
 12895         else if ( (!supportsWesternNumericIntegerOrReal &&
       
 12896                 iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari //&&
       
 12897                 //iLanguageCapabilities.iInputLanguageCode == ELangHindi
       
 12898                 )
       
 12899                 ||
       
 12900                 ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 12901                 iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeDevanagari && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 12902                 supportsWesternNumericIntegerOrReal &&
       
 12903                 TAknFepUiIndicInputManager::IsScriptDevanagari( iUiLanguage )
       
 12904                 )
       
 12905                 )
       
 12906             {
       
 12907             aNewState= EDevanagariIndicNumeric;                            
       
 12908             }
       
 12909         else
       
 12910         {
       
 12911         if ( iLanguageCapabilities.iInputLanguageCode == ELangArabic )
       
 12912             {
       
 12913             //iLanguageCapabilities.iLocalDigitType = EDigitTypeArabicIndic;
       
 12914             aNewState=EArabicIndicNumeric;
       
 12915             }
       
 12916         else if ( iLanguageCapabilities.iInputLanguageCode == ELangFarsi 
       
 12917                || iLanguageCapabilities.iInputLanguageCode == ELangUrdu )
       
 12918             {
       
 12919             //iLanguageCapabilities.iLocalDigitType = EDigitTypeEasternArabicIndic;
       
 12920             aNewState=EArabicIndicNumeric;
       
 12921             }    
       
 12922         else if ( iLanguageCapabilities.iInputLanguageCode == ELangHindi )
       
 12923             {
       
 12924             //iLanguageCapabilities.iLocalDigitType = EDigitTypeDevanagari;
       
 12925             aNewState= EDevanagariIndicNumeric;
       
 12926             }
       
 12927         }
       
 12928     }
       
 12929     
       
 12930 void CAknFepManager::UpdateLatinIndicator( TAknEditingState& aNewState )
       
 12931     {  
       
 12932     if (IsPredictive())
       
 12933         {
       
 12934         //AutoComplete - Begin
       
 12935         SetPredictiveIndicatorState( aNewState );
       
 12936         //AutoComplete - End
       
 12937 
       
 12938         return;           
       
 12939         }
       
 12940 
       
 12941     TInt currentCase = iCaseMan->CurrentCase();
       
 12942 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12943 	if(iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyLock)
       
 12944 		aNewState = EFnKeyLocked;
       
 12945     else if(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
 12946 		aNewState = EFnKeyPressed;
       
 12947 	else    
       
 12948 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 12949 		{
       
 12950 #ifdef RD_SCALABLE_UI_V2                        
       
 12951     if( iFepPluginManager &&
       
 12952         ( !iFepPluginManager->SyncWithPluginRange() || iFepPluginManager->PluginNativeRange() ) )
       
 12953         {
       
 12954         iFepPluginManager->SetPluginNativeRange( ETrue );
       
 12955 #endif // RD_SCALABLE_UI_V2 
       
 12956         switch ( iLanguageCapabilities.iInputLanguageCode )
       
 12957             {
       
 12958             case ELangArabic:
       
 12959                 {
       
 12960                 aNewState=EMultitapArabic; 
       
 12961                 }
       
 12962                 return;
       
 12963             case ELangHebrew:
       
 12964                 {
       
 12965                 aNewState=EMultitapHebrew;                              
       
 12966                 }
       
 12967                 return;
       
 12968             case ELangFarsi:
       
 12969             case ELangUrdu:
       
 12970                 {
       
 12971                 aNewState=EMultitapFarsiAndUrdu;                                 
       
 12972                 }
       
 12973                 return;
       
 12974             case ELangThai:
       
 12975                 {
       
 12976                 aNewState = EMultitapThai;                               
       
 12977                 }
       
 12978                 return;
       
 12979                 
       
 12980 #ifdef RD_MARATHI
       
 12981             case ELangMarathi:
       
 12982                 {
       
 12983                 aNewState = EIndicatorStateMultitapMarathi;                                
       
 12984                 }
       
 12985             	return;
       
 12986 #endif // RD_MARATHI
       
 12987 
       
 12988 #ifdef RD_HINDI_PHONETIC_INPUT  
       
 12989             case KLangHindiPhonetic:
       
 12990                 {                            
       
 12991                 TInt currentPtiLang = (ptiLang)? ptiLang->LanguageCode() : 0;
       
 12992                 
       
 12993                 if(TAknFepUiIndicInputManager::IsIndicPhoneticLanguage(TLanguage(currentPtiLang)))
       
 12994                     {
       
 12995                     aNewState = TAknEditingState(SetPhoneticIndicator(TLanguage(currentPtiLang)));
       
 12996                     }
       
 12997                 else
       
 12998                     {
       
 12999                      switch ( currentCase )
       
 13000                         {
       
 13001                         case EAknEditorUpperCase:
       
 13002                             aNewState=EMultitapUpper;
       
 13003                             if (iCharWidth == EFullWidthChar)
       
 13004                                 {
       
 13005                                 aNewState=EIndicatorStateFullLatinUpper;
       
 13006                                 }
       
 13007                             break;
       
 13008                         case EAknEditorLowerCase:
       
 13009                             aNewState=EMultitapLower;
       
 13010                             if (iCharWidth == EFullWidthChar)
       
 13011                                 {
       
 13012                                 aNewState=EIndicatorStateFullLatinLower;
       
 13013                                 }
       
 13014                             break;
       
 13015                         case EAknEditorTextCase:
       
 13016                             aNewState=EMultitapShifted;
       
 13017                             if (iCharWidth == EFullWidthChar)
       
 13018                                 {
       
 13019                                 aNewState=EIndicatorStateFullLatinText;
       
 13020                                 }
       
 13021                             break;
       
 13022                         default:
       
 13023                             break;
       
 13024                         }
       
 13025                     }       
       
 13026                 
       
 13027                 }
       
 13028             return;
       
 13029 #endif
       
 13030             case ELangVietnamese:
       
 13031                 {                          
       
 13032                 switch (currentCase)
       
 13033                     {
       
 13034                     case EAknEditorUpperCase:
       
 13035                         aNewState =  EMultitapUpperVietnamese;
       
 13036                         break;
       
 13037                     case EAknEditorLowerCase:
       
 13038                         aNewState =  EMultitapLowerVietnamese;
       
 13039                         break;
       
 13040                     case EAknEditorTextCase:
       
 13041                         aNewState = EMultitapShiftedVietnamese;
       
 13042                         break;
       
 13043                     default:
       
 13044                         break;
       
 13045                     }
       
 13046 				return;	  
       
 13047                 }
       
 13048                 
       
 13049             case ELangGreek:
       
 13050                 {
       
 13051                 switch (currentCase)
       
 13052                     {
       
 13053                     case EAknEditorUpperCase:
       
 13054                         aNewState =  EMultitapUpperGreek;
       
 13055                         break;
       
 13056                     case EAknEditorLowerCase:
       
 13057                         aNewState =  EMultitapLowerGreek;
       
 13058                         break;
       
 13059                     case EAknEditorTextCase:
       
 13060                         aNewState = EMultitapShiftedGreek;
       
 13061                         break;
       
 13062                     default:
       
 13063                         break;
       
 13064                     }
       
 13065 				return;  
       
 13066                 }
       
 13067             
       
 13068             //Cyrillic alphabet is used for Russian, Bulgarian and 
       
 13069             //Ukranian languages. So fall through for all these languages -
       
 13070             case ELangRussian:
       
 13071             case ELangBulgarian:
       
 13072             case ELangUkrainian:
       
 13073                 {
       
 13074                 switch (currentCase)
       
 13075                     {
       
 13076                     case EAknEditorUpperCase:
       
 13077                         aNewState =  EMultitapUpperCyrillic;
       
 13078                         break;
       
 13079                     case EAknEditorLowerCase:
       
 13080                         aNewState =  EMultitapLowerCyrillic;
       
 13081                         break;
       
 13082                     case EAknEditorTextCase:
       
 13083                         aNewState = EMultitapShiftedCyrillic;
       
 13084                         break;
       
 13085                     default:
       
 13086                         break;
       
 13087                     } 
       
 13088 				return; 
       
 13089                 }
       
 13090             }
       
 13091 #ifdef RD_SCALABLE_UI_V2     
       
 13092         }
       
 13093         // if plugin is not native range
       
 13094     
       
 13095     if(iFepPluginManager && iLanguageCapabilities.iInputLanguageCode != ELangRussian &&
       
 13096        iLanguageCapabilities.iInputLanguageCode != ELangBulgarian &&
       
 13097        iLanguageCapabilities.iInputLanguageCode != ELangUkrainian &&
       
 13098        iLanguageCapabilities.iInputLanguageCode != ELangGreek )
       
 13099         {
       
 13100         iFepPluginManager->SetPluginNativeRange( EFalse );
       
 13101         }
       
 13102     
       
 13103 #endif // RD_SCALABLE_UI_V2                                 
       
 13104 		}
       
 13105 #ifdef RD_INTELLIGENT_TEXT_INPUT		
       
 13106 	if(FnKeyState() == CAknFepFnKeyManager::EFnKeyNone)
       
 13107 #endif //RD_INTELLIGENT_TEXT_INPUT		
       
 13108 	    {
       
 13109         switch (currentCase)
       
 13110         {
       
 13111         case EAknEditorUpperCase:
       
 13112             aNewState=EMultitapUpper;
       
 13113             if (iCharWidth == EFullWidthChar)
       
 13114                 {
       
 13115                 aNewState=EIndicatorStateFullLatinUpper;
       
 13116                 }
       
 13117             break;
       
 13118         case EAknEditorLowerCase:
       
 13119             aNewState=EMultitapLower;
       
 13120             if (iCharWidth == EFullWidthChar)
       
 13121                 {
       
 13122                 aNewState=EIndicatorStateFullLatinLower;
       
 13123                 }
       
 13124             break;
       
 13125         case EAknEditorTextCase:
       
 13126             aNewState=EMultitapShifted;
       
 13127             if (iCharWidth == EFullWidthChar)
       
 13128                 {
       
 13129                 aNewState=EIndicatorStateFullLatinText;
       
 13130                 }
       
 13131             break;
       
 13132         default:
       
 13133             break;
       
 13134         }
       
 13135         }
       
 13136     }
       
 13137 void CAknFepManager::UpdateHindiIndicator( TAknEditingState& aNewState )
       
 13138     {
       
 13139     if ( IsPredictive() )
       
 13140         {
       
 13141         if( iIsAutoCompleteOn )
       
 13142             aNewState = EAutoCompleteHindi; 
       
 13143         else
       
 13144             aNewState = EIndicatorStatePredictiveHindi;
       
 13145         }
       
 13146     else
       
 13147         {
       
 13148         aNewState = EIndicatorStateMultitapHindi;
       
 13149         }
       
 13150     }
       
 13151 TBool CAknFepManager::GetIndicatorImgID(TInt& aIndicatorImgID, TInt& aIndicatorTextID)
       
 13152     {
       
 13153     if (iPreviousEditingState == EStateNone)
       
 13154         {
       
 13155         UpdateIndicators();
       
 13156         if (iPreviousEditingState == EStateNone)
       
 13157             {
       
 13158             return EFalse;    
       
 13159             }
       
 13160         }
       
 13161  
       
 13162 	TBool predictiveMode = QueryPredictiveState(iPreviousEditingState);
       
 13163 	TBool predictiveAutoCompleteMode = EFalse;
       
 13164 	if(!predictiveMode)
       
 13165 		{
       
 13166 		predictiveAutoCompleteMode = QueryPredictiveAutoCompleteState(iPreviousEditingState);		
       
 13167 		}
       
 13168     
       
 13169     if (predictiveMode)
       
 13170         {
       
 13171         aIndicatorImgID = EAknNaviPaneEditorIndicatorT9;
       
 13172         }
       
 13173     else if (predictiveAutoCompleteMode)
       
 13174         {
       
 13175         aIndicatorImgID = EAknNaviPaneEditorIndicatorAutoComplete;   
       
 13176         }
       
 13177     else 
       
 13178         {
       
 13179         aIndicatorImgID = EAknNaviPaneEditorIndicatorQuery;
       
 13180         }
       
 13181    
       
 13182     aIndicatorTextID = EvaluateState(iPreviousEditingState);
       
 13183     
       
 13184     return ETrue;
       
 13185     }
       
 13186     
       
 13187 TInt CAknFepManager::EvaluateState(const TAknEditingState aState)
       
 13188 {
       
 13189 	TInt result = 0;
       
 13190 	switch(aState)
       
 13191 	{
       
 13192 		case EArabicIndicNumeric:
       
 13193   			 result = EAknNaviPaneEditorIndicatorArabicIndicNumberCase;
       
 13194   			 break;
       
 13195   			 
       
 13196 		case ET9Thai:
       
 13197 		case EMultitapThai:
       
 13198 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13199 		case EAutoCompleteThai:
       
 13200 #endif
       
 13201 			result = EAknNaviPaneEditorIndicatorThai;
       
 13202 			break;				
       
 13203 			
       
 13204 		case EIndicatorStatePredictiveHindi:
       
 13205 		case EIndicatorStateMultitapHindi:
       
 13206 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13207 		case EAutoCompleteHindi:
       
 13208 #endif
       
 13209 #ifdef RD_MARATHI
       
 13210 		case EIndicatorStateMultitapMarathi:
       
 13211 		case EIndicatorStatePredictiveMarathi:
       
 13212 #endif // RD_MARATHI
       
 13213 			result = EAknNaviPaneEditorIndicatorDevanagariCase;
       
 13214 			break;	
       
 13215 			
       
 13216 		case ET9Arabic:
       
 13217 		case EMultitapArabic:
       
 13218 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13219 		case EAutoCompleteArabic:
       
 13220 #endif
       
 13221 			result = EAknNaviPaneEditorIndicatorArabicCase;
       
 13222 			break;	
       
 13223 
       
 13224 		case ET9Hebrew:
       
 13225 		case EMultitapHebrew:
       
 13226 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13227 		case EAutoCompleteHebrew:
       
 13228 #endif
       
 13229 			result = EAknNaviPaneEditorIndicatorHebrewCase;
       
 13230 			break;	
       
 13231 			
       
 13232 		case ET9FarsiAndUrdu:
       
 13233 		case EMultitapFarsiAndUrdu:
       
 13234 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13235 		case EAutoCompleteFarsiAndUrdu:
       
 13236 #endif
       
 13237 			result = EAknNaviPaneEditorIndicatorFarsiAndUrduCase;
       
 13238 			break;					
       
 13239 
       
 13240 
       
 13241 		case ET9Upper:
       
 13242 		case EMultitapUpper:
       
 13243 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13244 		case EAutoCompleteUpper:
       
 13245 #endif
       
 13246 			result = EAknNaviPaneEditorIndicatorUpperCase;	
       
 13247 			break;
       
 13248 
       
 13249 		case ET9Lower:
       
 13250 		case EMultitapLower:
       
 13251 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13252 		case EAutoCompleteLower:
       
 13253 #endif
       
 13254 			result = EAknNaviPaneEditorIndicatorLowerCase;	
       
 13255 			break;
       
 13256 
       
 13257 		case ET9Shifted:
       
 13258 		case EMultitapShifted:
       
 13259 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13260 		case EAutoCompleteShifted:
       
 13261 #endif
       
 13262 			result = EAknNaviPaneEditorIndicatorTextCase;	
       
 13263 			break;
       
 13264 			
       
 13265 		case ENumeric:
       
 13266 			result = EAknNaviPaneEditorIndicatorNumberCase;	
       
 13267 			break;		
       
 13268   			 
       
 13269   			 	
       
 13270 		case EIndicatorStatePinyin:
       
 13271 			result = EAknNaviPaneEditorIndicatorPinyin;
       
 13272 			break;
       
 13273 		case EIndicatorStatePinyinPhrase:
       
 13274 			result = EAknNaviPaneEditorIndicatorPinyinPhrase;
       
 13275 			break;
       
 13276 			
       
 13277 		case EIndicatorStateZhuyin:
       
 13278 			 result = EAknNaviPaneEditorIndicatorZhuyin;
       
 13279 			break;
       
 13280 		case EIndicatorStateZhuyinPhrase:
       
 13281 			 result = EAknNaviPaneEditorIndicatorZhuyinPhrase;
       
 13282 			break;
       
 13283 
       
 13284 		case EIndicatorStateZhuyinFind:
       
 13285 			result = EAknNaviPaneEditorIndicatorZhuyinFind;
       
 13286 			break;
       
 13287 
       
 13288 		case EDevanagariIndicNumeric :
       
 13289 			result = EAknNaviPaneEditorIndicatorDevanagariIndicNumberCase;
       
 13290 			break;
       
 13291 		
       
 13292 		case EIndicatorStateHiraganaKanji:
       
 13293 		case EIndicatorStateJapanesePredictive:
       
 13294 			result = EAknNaviPaneEditorIndicatorJapaneseHiraganaKanji;
       
 13295 			break;
       
 13296 
       
 13297 		case EIndicatorStateFullKatakana:
       
 13298 			result = EAknNaviPaneEditorIndicatorJapaneseFullKatakana;
       
 13299 			break;
       
 13300 
       
 13301 		case EIndicatorStateHalfKatakana:
       
 13302 			result = EAknNaviPaneEditorIndicatorJapaneseHalfKatakana;
       
 13303 			break;
       
 13304 
       
 13305 		case EIndicatorStateFullLatinText:
       
 13306 			result = EAknNaviPaneEditorIndicatorJapaneseFullTextAlphabet;
       
 13307 			break;
       
 13308 
       
 13309 		case EIndicatorStateFullLatinUpper:
       
 13310 			result = EAknNaviPaneEditorIndicatorJapaneseFullUpperAlphabet;
       
 13311 			break; 
       
 13312 
       
 13313 		case EIndicatorStateFullLatinLower:
       
 13314 			result = EAknNaviPaneEditorIndicatorJapaneseFullLowerAlphabet;
       
 13315 			break;
       
 13316 
       
 13317 		case EIndicatorStateFullNumeric:
       
 13318 			result = EAknNaviPaneEditorIndicatorJapaneseFullNumeric;
       
 13319 			break;
       
 13320 
       
 13321 		case EIndicatorStateHiragana:
       
 13322 			result = EAknNaviPaneEditorIndicatorJapaneseHiragana;
       
 13323 			break;
       
 13324 
       
 13325 		case EIndicatorStateStroke:
       
 13326 			result = EAknNaviPaneEditorIndicatorStroke;
       
 13327 			break;
       
 13328 		case EIndicatorStateStrokePhrase:
       
 13329 			result = EAknNaviPaneEditorIndicatorStrokePhrase;
       
 13330 			break;
       
 13331 
       
 13332 		case EIndicatorStateStrokeTrad:
       
 13333 			result = EAknNaviPaneEditorIndicatorStrokeTrad;
       
 13334 			break;
       
 13335 		case EIndicatorStateStrokeTradPhrase:
       
 13336 			result = EAknNaviPaneEditorIndicatorStrokeTradPhrase;
       
 13337 			break;
       
 13338 
       
 13339 		case EQwertyShift:
       
 13340 			result = EAknNaviPaneEditorIndicatorQwertyShift;
       
 13341 			break;
       
 13342 
       
 13343 		case EIndicatorStateStrokeFind:
       
 13344 			result = EAknNaviPaneEditorIndicatorStrokeFind;
       
 13345 			break;
       
 13346 
       
 13347 		case EIndicatorStateCangJie:
       
 13348 			result = EAknNaviPaneEditorIndicatorCangJie;
       
 13349 			break;
       
 13350 		
       
 13351 		case ET9UpperVietnamese:
       
 13352 		case EMultitapUpperVietnamese:
       
 13353 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13354 		case EAutoCompleteUpperVietnamese:
       
 13355 #endif
       
 13356 			result = EAknNaviPaneEditorIndicatorVietnameseUpperCase;
       
 13357 			break;			
       
 13358 			
       
 13359 		case ET9LowerVietnamese:
       
 13360 		case EMultitapLowerVietnamese:
       
 13361 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13362 		case EAutoCompleteLowerVietnamese:
       
 13363 #endif
       
 13364 			result = EAknNaviPaneEditorIndicatorVietnameseLowerCase;
       
 13365 			break;	
       
 13366 			
       
 13367 		case ET9ShiftedVietnamese:
       
 13368 		case EMultitapShiftedVietnamese:
       
 13369 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13370 		case EAutoCompleteShiftedVietnamese:
       
 13371 #endif
       
 13372 			result = EAknNaviPaneEditorIndicatorVietnameseTextCase;
       
 13373 			break;
       
 13374 #ifdef RD_HINDI_PHONETIC_INPUT	
       
 13375 		case EIndicatorStateHindiPhoneticUpper:
       
 13376 			result = EAknNaviPaneEditorIndicatorDevanagariPhoneticUpperCase;
       
 13377 			break;
       
 13378 		case EIndicatorStateHindiPhoneticLower:
       
 13379 			result = EAknNaviPaneEditorIndicatorDevanagariPhoneticLowerCase;
       
 13380 			break;
       
 13381 #endif
       
 13382         case ET9UpperGreek:
       
 13383         case EMultitapUpperGreek:
       
 13384             result = EAknNaviPaneEditorIndicatorGreekUpperCase;
       
 13385             break;
       
 13386             
       
 13387         case ET9LowerGreek:
       
 13388         case EMultitapLowerGreek:
       
 13389             result = EAknNaviPaneEditorIndicatorGreekLowerCase;
       
 13390             break;
       
 13391         
       
 13392         case ET9ShiftedGreek:
       
 13393         case EMultitapShiftedGreek:
       
 13394             result = EAknNaviPaneEditorIndicatorGreekTextCase;
       
 13395             break;
       
 13396             
       
 13397         case ET9UpperCyrillic:
       
 13398         case EMultitapUpperCyrillic:
       
 13399             result = EAknNaviPaneEditorIndicatorCyrillicUpperCase;
       
 13400             break;
       
 13401             
       
 13402         case ET9LowerCyrillic:
       
 13403         case EMultitapLowerCyrillic:
       
 13404             result = EAknNaviPaneEditorIndicatorCyrillicLowerCase;
       
 13405             break;
       
 13406         
       
 13407         case ET9ShiftedCyrillic:
       
 13408         case EMultitapShiftedCyrillic:
       
 13409             result = EAknNaviPaneEditorIndicatorCyrillicTextCase;
       
 13410             break;
       
 13411             
       
 13412         case EHybridModeLatin:
       
 13413             result = EAknNaviPaneEditorIndicatorHybridLatin;
       
 13414             break;
       
 13415         case EIndicatorStateHangul:
       
 13416             result = EAknNaviPaneEditorIndicatorKoreanHangul;
       
 13417             break;
       
 13418         
       
 13419 	}
       
 13420 	return result;
       
 13421 
       
 13422 }    
       
 13423 
       
 13424 TBool CAknFepManager::IsAbleToLaunchSCT() const
       
 13425     {
       
 13426     TBool ableToLaunchSCT = ETrue;
       
 13427 
       
 13428     if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT && 
       
 13429         PluginInputMode() == EPluginInputModeNone )
       
 13430         {
       
 13431         // The editor doesn't allow SCT.
       
 13432         return EFalse;
       
 13433         }
       
 13434 
       
 13435     if (iMode == ENumber || iMode == ENativeNumber)
       
 13436         {
       
 13437         if (iPermittedInputModes == EAknEditorNumericInputMode || !NumericModeSCTResourceId()) 
       
 13438             {
       
 13439             // SCT is not launched if the number mode is the only input mode or
       
 13440             // if there is not keymap resource for the current numeric keymap mode.
       
 13441             ableToLaunchSCT = EFalse;
       
 13442             }
       
 13443         if (iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap ||
       
 13444             ( (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap) &&
       
 13445               (iPermittedInputModes != EAknEditorNumericInputMode) ))
       
 13446             {
       
 13447             // SCT is launched in the number mode if requested by editor flag
       
 13448             // EAknEditorFlagUseSCTNumericCharmap or if also text input modes are
       
 13449             // allowed and the keymap is EAknEditorAlphanumericNumberModeKeymap.
       
 13450             ableToLaunchSCT = ETrue;
       
 13451             }
       
 13452         }
       
 13453     if (!(EditorHasFreeSpace() && EditorState() 
       
 13454         && EditorState()->SpecialCharacterTableResourceId()))
       
 13455         {
       
 13456         ableToLaunchSCT = EFalse;
       
 13457         }
       
 13458 
       
 13459     return ableToLaunchSCT;
       
 13460     }
       
 13461 
       
 13462 TBool CAknFepManager::QueryPredictiveState(const TAknEditingState aState)
       
 13463  { 
       
 13464     return  (( aState == EIndicatorStatePinyin) ||
       
 13465              ( aState == EIndicatorStatePinyinPhrase) ||
       
 13466              ( aState == EIndicatorStateZhuyin) ||
       
 13467              ( aState == EIndicatorStateZhuyinPhrase) ||
       
 13468              ( aState == EIndicatorStateZhuyinFind) ||
       
 13469              ( aState == EIndicatorStateStrokeFind) ||
       
 13470              ( aState == EIndicatorStateStroke) || 
       
 13471              ( aState == EIndicatorStateStrokePhrase) ||
       
 13472 			 ( aState == EIndicatorStateCangJie) ||
       
 13473              ( aState == EIndicatorStateStrokeTrad) || 
       
 13474              ( aState == EIndicatorStateStrokeTradPhrase) ||
       
 13475              ( aState == ET9Upper) ||
       
 13476              ( aState == ET9Shifted) ||
       
 13477              ( aState == ET9Lower) ||
       
 13478              ( aState == ET9Arabic) ||
       
 13479              ( aState == ET9Hebrew) ||
       
 13480              ( aState == ET9FarsiAndUrdu) ||
       
 13481              ( aState == ET9Thai) ||
       
 13482              ( aState == EIndicatorStatePredictiveHindi) ||
       
 13483 #ifdef RD_MARATHI
       
 13484              ( aState == EIndicatorStatePredictiveMarathi) ||
       
 13485 #endif // RD_MARATHI
       
 13486              ( aState == EIndicatorStateJapanesePredictive) ||
       
 13487              ( aState == ET9UpperVietnamese) ||
       
 13488              ( aState == ET9LowerVietnamese) ||
       
 13489              ( aState == ET9ShiftedVietnamese) ||
       
 13490              ( aState == ET9UpperGreek) ||
       
 13491              ( aState == ET9LowerGreek) ||
       
 13492              ( aState == ET9ShiftedGreek) ||
       
 13493              ( aState == ET9UpperCyrillic) ||
       
 13494              ( aState == ET9LowerCyrillic) ||
       
 13495              ( aState == ET9ShiftedCyrillic) );  
       
 13496  }
       
 13497 
       
 13498  TBool CAknFepManager::QueryPredictiveAutoCompleteState(TAknEditingState aState)
       
 13499  {
       
 13500  	 	        
       
 13501     return (( aState == EAutoCompleteUpper ) ||  
       
 13502      		( aState == EAutoCompleteShifted )  ||
       
 13503      		( aState == EAutoCompleteLower ) || 
       
 13504      		( aState == EAutoCompleteHindi ) ||
       
 13505      		( aState == EAutoCompleteArabic ) ||
       
 13506      		( aState == EAutoCompleteHebrew ) ||
       
 13507      		( aState == EAutoCompleteFarsiAndUrdu ) ||
       
 13508      		( aState == EAutoCompleteThai ) ||
       
 13509      		( aState == EAutoCompleteUpperVietnamese ) ||
       
 13510      		( aState == EAutoCompleteLowerVietnamese ) ||
       
 13511      		( aState == EAutoCompleteShiftedVietnamese ));
       
 13512  }
       
 13513 
       
 13514 void CAknFepManager::LaunchSpecialCharacterTableL(TInt aResourceId, TBool aLaunchedByTouchWin, TBool aSmileyFirst)
       
 13515     {
       
 13516 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 13517     // Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
 13518 	// between two words and SCT is launched
       
 13519     iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
 13520 #endif //RD_INTELLIGENT_TEXT_INPUT    
       
 13521 #ifdef RD_SCALABLE_UI_V2
       
 13522     if ( iStarKeyPressed && iFepPluginManager && 
       
 13523          iFepPluginManager->PluginInputMode() == EPluginInputModeItut )
       
 13524             {
       
 13525             aLaunchedByTouchWin = ETrue;
       
 13526             }
       
 13527     iCancelPopupInQwerty = aLaunchedByTouchWin;
       
 13528 #endif //RD_SCALABLE_UI_V2
       
 13529     DoLaunchSctAndPctL(aResourceId, aSmileyFirst ? EShowSmileyFirst : EShowSctFirst );
       
 13530 #ifdef RD_SCALABLE_UI_V2
       
 13531     iCancelPopupInQwerty = EFalse;
       
 13532 #endif //RD_SCALABLE_UI_V2    
       
 13533 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 13534     iSupressCursorMoveToEndChrKeyPressed = ETrue;  
       
 13535 #endif //RD_INTELLIGENT_TEXT_INPUT     
       
 13536     }
       
 13537 
       
 13538 TBool CAknFepManager::IsAbleToLaunchPCT() const
       
 13539     {
       
 13540     TBool isAbleToLaunch = EFalse;
       
 13541     if (FeatureManager::FeatureSupported(KFeatureIdJapanesePicto)
       
 13542      && (iAknEditorFlags & EAknEditorFlagEnablePictographInput))
       
 13543         {
       
 13544         isAbleToLaunch = ETrue;
       
 13545         }
       
 13546     return isAbleToLaunch;
       
 13547     }
       
 13548 
       
 13549 TBool CAknFepManager::IsAbleToLaunchSmiley() const
       
 13550     {
       
 13551     TBool ableToLaunchSmiley(EFalse);
       
 13552     
       
 13553     CAknEdwinState* edwinState = EditorState();
       
 13554     if(edwinState)
       
 13555         {
       
 13556         CAknEdwinFormAccessor* formAccessor = edwinState->FormAccessor();
       
 13557         if(formAccessor)
       
 13558             {
       
 13559             CEikEdwin *edwin = static_cast<CEikEdwin*>(formAccessor->FormClientControl());
       
 13560             if(edwin)
       
 13561                 {
       
 13562                 ableToLaunchSmiley = ((edwin->UserFlags()&CEikEdwin::EAvkonEnableSmileySupport) != 0);
       
 13563                 }
       
 13564             }
       
 13565         }
       
 13566 
       
 13567     return ableToLaunchSmiley;
       
 13568     }
       
 13569 
       
 13570 TInt CAknFepManager::GetCurrentEditorSCTResId() const
       
 13571     {
       
 13572     if(!EditorState())
       
 13573         {
       
 13574     	return NumericModeSCTResourceId();    	
       
 13575         }
       
 13576     TInt currentEditorSCTResId = EditorState()->SpecialCharacterTableResourceId();
       
 13577     if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 13578         {        
       
 13579         if (currentEditorSCTResId == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 13580             {
       
 13581             if (iMode == EZhuyin)
       
 13582             	{
       
 13583             	currentEditorSCTResId = 
       
 13584                                   R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_FOR_ZHUYIN_SYMBOL_INPUT;
       
 13585         	    }
       
 13586             else
       
 13587             	{
       
 13588             	currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 13589         	    }        
       
 13590             }
       
 13591         }
       
 13592     if (currentEditorSCTResId == EDefaultSCTResourceId) // -1 forces the default in SCT resource definition
       
 13593         {
       
 13594         if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
 13595             {
       
 13596             currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY;
       
 13597             }        
       
 13598         else	
       
 13599             {        		        	
       
 13600             // only ITU-T and when Bopomofo symbol input mode is supported, we use new sct table
       
 13601             TInt supportSCTToneMarks = EFalse;
       
 13602             MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineZhuyin);
       
 13603             
       
 13604             if(ptiCoreInfo)
       
 13605                 {
       
 13606                 supportSCTToneMarks = ptiCoreInfo->CapsBits() & ESupportSCTToneMarks;
       
 13607                 }
       
 13608             
       
 13609             ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineZhuyinByPhrase);
       
 13610             if(ptiCoreInfo)    
       
 13611                 {
       
 13612                 supportSCTToneMarks = supportSCTToneMarks || 
       
 13613                                       (ptiCoreInfo->CapsBits() & ESupportSCTToneMarks);
       
 13614                 }
       
 13615             
       
 13616             if(!iQwertyInputMode && (iMode == EZhuyin) && supportSCTToneMarks)
       
 13617                 {
       
 13618                 currentEditorSCTResId = 
       
 13619                                   R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_FOR_ZHUYIN_SYMBOL_INPUT;
       
 13620                 }
       
 13621             else
       
 13622                 {
       
 13623                 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 13624                     {    
       
 13625                     currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 13626                     }
       
 13627                 else
       
 13628                     {                    
       
 13629                     currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
       
 13630                     }
       
 13631                 }
       
 13632             }
       
 13633         }  
       
 13634     return currentEditorSCTResId;         
       
 13635     }
       
 13636 
       
 13637 void CAknFepManager::LaunchPictographCharacterTableL()
       
 13638     {
       
 13639     DoLaunchSctAndPctL(NULL, EShowPctFirst);
       
 13640     }
       
 13641 
       
 13642 
       
 13643 void CAknFepManager::UpdateInlineEditL(const TDesC& aNewInlineText, 
       
 13644                                        TInt aPositionOfInsertionPointInInlineText)
       
 13645     {
       
 13646     if ( ! IsFlagSet ( EFlagInsideInlineEditingTransaction ) )
       
 13647         {
       
 13648         return;
       
 13649         }
       
 13650     // Japanese implementation needs to be merged with functionality of other languages. Now they are separate.
       
 13651     if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 13652         {
       
 13653         iUncommittedText.iCursorPos = iUncommittedText.iAnchorPos + 
       
 13654                                       aPositionOfInsertionPointInInlineText;
       
 13655 
       
 13656         if (aNewInlineText.Length() == 1)
       
 13657             {
       
 13658             if (aNewInlineText[0] == KAknFEPLineFeedSymbol ||
       
 13659                 aNewInlineText[0] == KAknFEPMirroredLineFeedSymbol)
       
 13660                 {
       
 13661                 SetFlag(EFlagLineFeedCharacter);
       
 13662                 ClearFlag(EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 13663                 }
       
 13664             else if (aNewInlineText[0] == iSpaceCharacterCode)
       
 13665                 {
       
 13666                 SetFlag(EFlagSpaceCharacter);
       
 13667                 ClearFlag(EFlagLineFeedCharacter | EFlagFullWidthSpaceCharacter);
       
 13668                 }
       
 13669             else if (aNewInlineText[0] == iFullWidthSpaceCharacterCode)
       
 13670                 {
       
 13671                 SetFlag(EFlagFullWidthSpaceCharacter);
       
 13672                 ClearFlag(EFlagLineFeedCharacter | EFlagSpaceCharacter);
       
 13673                 }
       
 13674             else
       
 13675                 {
       
 13676                 ClearFlag(EFlagLineFeedCharacter 
       
 13677                           | EFlagSpaceCharacter 
       
 13678                           | EFlagFullWidthSpaceCharacter);
       
 13679                 }
       
 13680             if (iInputCapabilities.SupportsSecretText())
       
 13681                 {
       
 13682                 TBuf<1> buf;
       
 13683                 buf.Append(aNewInlineText[0]);
       
 13684                 NewCharacterL(buf);
       
 13685                 }
       
 13686             else
       
 13687                 {
       
 13688                 SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
 13689                 iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(aNewInlineText, 
       
 13690                                                   aPositionOfInsertionPointInInlineText);
       
 13691                 }
       
 13692             }
       
 13693         else
       
 13694             {
       
 13695             ClearFlag(EFlagLineFeedCharacter | EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 13696             iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(aNewInlineText, 
       
 13697                                                    aPositionOfInsertionPointInInlineText);
       
 13698             }
       
 13699 #ifdef _DEBUG
       
 13700         RDebug::Print(_L("UpdateInlineEditL text=[%S] len=[%d] CurPos=[%d] AncPos=[%d] change=[%d]"),
       
 13701             &aNewInlineText, iUncommittedText.Length(),
       
 13702             iUncommittedText.iCursorPos, iUncommittedText.iAnchorPos,
       
 13703             aPositionOfInsertionPointInInlineText);
       
 13704 #endif
       
 13705         }
       
 13706     else
       
 13707         {
       
 13708         	TInt curPos = iUncommittedText.iAnchorPos + aNewInlineText.Length();
       
 13709         	
       
 13710         	TInt deltaCur = curPos - iUncommittedText.iCursorPos;
       
 13711         	
       
 13712         	TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 13713         	
       
 13714         	TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 13715         	
       
 13716         	HBufC* newInlineText=NULL;
       
 13717 	        	
       
 13718         	TBool syncLater = ETrue;
       
 13719 			// we have to restrict to a length that is permissible in the editor
       
 13720         	// this situation comes when we select the max length condition is reached 
       
 13721         	// in the editor and we navigate to one of the words in the middle 
       
 13722         	// and select a longer word from the candidate list        	
       
 13723         	
       
 13724 
       
 13725         	if( (maxEdSize > 0) && ( deltaCur > 0 ) 
       
 13726         							&& (( docLength + deltaCur) > maxEdSize ) )
       
 13727         	{
       
 13728         		newInlineText= aNewInlineText.Left( aNewInlineText.Length() - (docLength + deltaCur - maxEdSize )).AllocLC();
       
 13729         		aPositionOfInsertionPointInInlineText=newInlineText->Length();
       
 13730         	}
       
 13731         	else if((maxEdSize > 0) && (curPos > maxEdSize))
       
 13732         	{
       
 13733         		newInlineText= aNewInlineText.Left(maxEdSize - iUncommittedText.iAnchorPos).AllocLC();
       
 13734         		aPositionOfInsertionPointInInlineText=newInlineText->Length();
       
 13735         	}        	
       
 13736         	else
       
 13737         	{
       
 13738         		newInlineText=aNewInlineText.AllocLC();
       
 13739         		syncLater = EFalse;        	
       
 13740         	} 
       
 13741 	// The Below code changes are made to sync iTextBuffer and the last word in the editor.When the 
       
 13742 	// cursor position reaches more than the max length of editor, tail length is modified according 
       
 13743 	// to truncated last word and Autocompletion bit length (Element count) value to display last 
       
 13744 	// word in the editor properly. 			       	        	        	
       
 13745     #ifdef RD_INTELLIGENT_TEXT_INPUT        	 	
       
 13746 			if(syncLater)
       
 13747         	    {       	    
       
 13748     	        TBuf<CAknFepManager::EMaximumFepWordLength> currentText = iPtiEngine->CurrentWord();
       
 13749     	        currentText.SetLength(newInlineText->Length());        	        
       
 13750     	        iPtiEngine->HandleCommandL( EPtiCommandSetCursorCrossedMaxLength );
       
 13751     	        iPtiEngine->SetCurrentWord(currentText); 
       
 13752     	        TransferFepStateToEditorL();
       
 13753     	        iPtiEngine->HandleCommandL( EPtiCommandResetCursorCrossedMaxLength );
       
 13754         	    }
       
 13755 	#endif 	
       
 13756         	// CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 13757         	iUncommittedText.iCursorPos = iUncommittedText.iAnchorPos + aPositionOfInsertionPointInInlineText;
       
 13758 
       
 13759 		HBufC* decoratedInlineEdit = HBufC::NewLC(aNewInlineText.Length()*3);
       
 13760 		TPtr bufferPtr(decoratedInlineEdit->Des());
       
 13761 
       
 13762         if ( EditorSupportsNeutralProtection() )
       
 13763             {
       
 13764         		if ( newInlineText->Length() > 0 )
       
 13765                 {
       
 13766                 iInlineTextDecorator->DecorateInlineText(
       
 13767         			newInlineText->Des(),
       
 13768                     bufferPtr,
       
 13769                     aPositionOfInsertionPointInInlineText,
       
 13770                     static_cast<TChar>(PreviousChar()),
       
 13771                     IsRightToLeftParagraph(DocPos() ),
       
 13772                     ( CurrentInputDirectionality() == TBidiText::ERightToLeft ) );
       
 13773                 }
       
 13774 
       
 13775             // Because the length of the new inline edit may bear no relation to the old inline edit,
       
 13776             // the passed desired position of the cursor (which is hidden in S60 anyway) in the new
       
 13777             // inline edit is restricted to its Length(). The input value of parameter
       
 13778             // aPositionOfInsertionPointInInlineText is ignored, and its modified value
       
 13779             // from the DecorateInlineText routine is also ignored.
       
 13780             
       
 13781 			aPositionOfInsertionPointInInlineText = decoratedInlineEdit->Length();
       
 13782 
       
 13783             iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(
       
 13784                 bufferPtr, aPositionOfInsertionPointInInlineText);
       
 13785             	
       
 13786             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 13787             iUncommittedText.iAnchorPos-=decoratedInlineEdit->Length();
       
 13788         	}
       
 13789 
       
 13790         	else
       
 13791         	{
       
 13792         		// Even without the issue of decoration, the length of the new inline edit may bear no
       
 13793         		// relation to the old inline edit. It is always set to length (the end) of the new inline edit
       
 13794         		aPositionOfInsertionPointInInlineText = newInlineText->Length();
       
 13795 
       
 13796         		iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(
       
 13797         			newInlineText->Des(), aPositionOfInsertionPointInInlineText);
       
 13798 
       
 13799         		// This is needed here too because we should not insist that the new text is the same length
       
 13800         		// as the old, and so the iUncommitted text should be reset.
       
 13801         		iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 13802         		iUncommittedText.iAnchorPos-=newInlineText->Length();
       
 13803         	}       
       
 13804 
       
 13805         	
       
 13806         CleanupStack::PopAndDestroy(decoratedInlineEdit);  
       
 13807         SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncUpdatedText );
       
 13808         CleanupStack::PopAndDestroy(newInlineText);
       
 13809         //Send info to engine to set EPtiXt9FlagAutoCompletionSetOnToOff flag as false 
       
 13810         TInt value = 0;
       
 13811         TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandAutoCompletionOnToOff,&value));			
       
 13812         }  
       
 13813     }
       
 13814 
       
 13815 void CAknFepManager::StartInlineEditL()
       
 13816     {
       
 13817     if(iConcatenationTimer->IsActive())
       
 13818     	iConcatenationTimer->Cancel();
       
 13819 	
       
 13820     //currently western only, would need to sort out flags if this were to be used
       
 13821     //in multitap modes
       
 13822     switch (iMode)
       
 13823         {
       
 13824         case ELatin:
       
 13825         case EKatakana:
       
 13826         case EHiragana:
       
 13827             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(KNullDesC, 0, EFalse, 
       
 13828                                                                          NULL, *this, *this);
       
 13829             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 13830             break;
       
 13831         default:
       
 13832             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(KNullDesC, 0, EFalse, 
       
 13833                                                                          NULL, *this, *this);
       
 13834             break;
       
 13835         }
       
 13836 #ifdef _DEBUG
       
 13837     RDebug::Print(_L("StartInlineEditL len=[%d] CurPos=[%d] AncPos=[%d]"),
       
 13838         iUncommittedText.Length(),
       
 13839         iUncommittedText.iCursorPos, iUncommittedText.iAnchorPos );
       
 13840 #endif
       
 13841 
       
 13842     // have to calculate the number of free space on current EDITOR after StartFepInlineEditL().
       
 13843     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 13844     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 13845     iFreeSpaceOfEditor = maxEdSize - edSize;
       
 13846 
       
 13847     SetFlag(EFlagInsideInlineEditingTransaction);
       
 13848     }
       
 13849 
       
 13850 void CAknFepManager::StartInlineEditL(const TDesC& aText)
       
 13851     {
       
 13852     if(iConcatenationTimer->IsActive())
       
 13853     	iConcatenationTimer->Cancel();
       
 13854 	
       
 13855     TInt textLength = aText.Length();
       
 13856 
       
 13857     // CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 13858     
       
 13859 	HBufC* decoratedInlineEdit = HBufC::NewLC(aText.Length()*3);
       
 13860 	TPtr bufferPtr(decoratedInlineEdit->Des());
       
 13861 
       
 13862     // decorate the inline edit
       
 13863     if( aText.Length() > 0 && EditorSupportsNeutralProtection() )
       
 13864         {
       
 13865         iInlineTextDecorator->DecorateInlineText(
       
 13866             aText,
       
 13867             bufferPtr,
       
 13868             textLength, // aPositionOfInsertionPointInInlineText,
       
 13869             static_cast<TChar>(PreviousChar()),
       
 13870             IsRightToLeftParagraph( DocPos() ),
       
 13871             ( CurrentInputDirectionality() == TBidiText::ERightToLeft ) );
       
 13872         }
       
 13873     else
       
 13874         {
       
 13875 
       
 13876         bufferPtr.Copy(aText);
       
 13877         }
       
 13878     
       
 13879     // Before starting editor inline, we cancel editor inline if by any chance editor ends up in inline edit and fep does not
       
 13880         TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); 
       
 13881         
       
 13882         if(phoneIdle)
       
 13883             {
       
 13884             iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
 13885             }
       
 13886     
       
 13887     // operates at the current insertion point or selection
       
 13888     iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(
       
 13889 
       
 13890         bufferPtr,
       
 13891         textLength, // aPositionOfInsertionPointInInlineText,
       
 13892         EFalse,  // Cursor visibility
       
 13893         0, // MFormCustomDrawer*
       
 13894         *this,
       
 13895         *this);
       
 13896 
       
 13897     // CleanupStack::Pop(); // cleanupitem for FEP state.
       
 13898 
       
 13899     if (!iInputCapabilities.FepAwareTextEditor())
       
 13900         {
       
 13901         // In case while starting the inline edit, 3rd party app removes the focus out of editor before the transaction
       
 13902         // completes, we return with an error.
       
 13903         User::Leave(KErrCorrupt);
       
 13904         }
       
 13905     // cursor span needs to be updated following potential modification
       
 13906     // of the inline edit content before it was started
       
 13907     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 13908 	iUncommittedText.iAnchorPos-=decoratedInlineEdit->Length();
       
 13909 	CleanupStack::PopAndDestroy(decoratedInlineEdit);
       
 13910 
       
 13911     SetFlag(EFlagInsideInlineEditingTransaction);
       
 13912     }
       
 13913 
       
 13914 void CAknFepManager::StartInlineEditL(TCursorSelection aCursorSelection, 
       
 13915                                       const TDesC& aInitialInlineText, 
       
 13916                                       TInt aPositionOfInsertionPointInInlineText, 
       
 13917                                       TBool aCursorVisibility)
       
 13918     {
       
 13919     	
       
 13920 		if(iConcatenationTimer->IsActive())
       
 13921     	iConcatenationTimer->Cancel();
       
 13922 	
       
 13923     TBool setToTrue=EFalse;
       
 13924 
       
 13925     // setToTrue parameter forces use of selection hiding inline edit editor API -
       
 13926     // this method also sets the cursor selection to the second parameter
       
 13927     // CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 13928     iInputCapabilities.FepAwareTextEditor()->Extension1()->StartFepInlineEditL(
       
 13929         setToTrue,
       
 13930         aCursorSelection,
       
 13931         aInitialInlineText,
       
 13932         aPositionOfInsertionPointInInlineText,
       
 13933         aCursorVisibility,
       
 13934         0, // MFormCustomDrawer* ?
       
 13935         *this,
       
 13936         *this);
       
 13937     // CleanupStack::Pop(); // cleanupitem for FEP state.
       
 13938     SetFlag(EFlagInsideInlineEditingTransaction);
       
 13939     //This will suppress Edit submenu from poping up
       
 13940     SetCcpuFlag(ECcpuStateIgnoreStarUp);
       
 13941     }
       
 13942 
       
 13943 TBool CAknFepManager::CloseUiIfWordDeletedL()
       
 13944     {
       
 13945     if (iUncommittedText.Length()==0)
       
 13946         {
       
 13947         // word has been totally deleted
       
 13948         ClearFlag(EFlagCompoundWord);
       
 13949         TryCloseUiL();
       
 13950         return ETrue;
       
 13951         }
       
 13952     return EFalse;
       
 13953     }
       
 13954 
       
 13955 TBool CAknFepManager::TryGetTextToUncommitL(TDes& aText, TInt aCode, TBool& aComsumeKey)
       
 13956     {
       
 13957     TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 13958     if (aCode == EKeyLeftArrow)
       
 13959         {
       
 13960         naviEvent = ELeftNaviEvent;
       
 13961         }
       
 13962     else if (aCode == EKeyRightArrow)
       
 13963         {
       
 13964         naviEvent = ERightNaviEvent;
       
 13965         }
       
 13966     else if (aCode == EKeyBackspace)
       
 13967         {
       
 13968         naviEvent = EBackspaceEvent;
       
 13969         }
       
 13970 
       
 13971     TInt nextCharPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 13972     TBool hindibackspace = 0 ;  
       
 13973     TBool nextPositionFound = EFalse;
       
 13974     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 13975     if ( naviEvent == ERightNaviEvent )
       
 13976         {
       
 13977         nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 13978         if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) || 
       
 13979                 (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 13980             {
       
 13981             FindStartOfWord(nextCharPos);   
       
 13982                         
       
 13983             if(nextCharPos < iUncommittedText.LowerPos())
       
 13984                 {
       
 13985                 nextCharPos = iUncommittedText.LowerPos();
       
 13986                 }
       
 13987             }
       
 13988         }
       
 13989     else if ( naviEvent == ELeftNaviEvent )
       
 13990         {
       
 13991         nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 13992         if( nextPositionFound && (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 13993                 (nextPositionFound && (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai)))
       
 13994             {
       
 13995             FindEndOfWord(nextCharPos);
       
 13996             if(nextCharPos > iUncommittedText.HigherPos())
       
 13997                 {
       
 13998                 nextCharPos = iUncommittedText.HigherPos();
       
 13999                 }
       
 14000             }
       
 14001             
       
 14002         }
       
 14003     else if ( naviEvent == EBackspaceEvent )
       
 14004         {
       
 14005         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 14006             {
       
 14007             nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 14008             }
       
 14009         else
       
 14010             {
       
 14011             if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14012                     (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14013                 {
       
 14014                 TCursorSelection curSel;
       
 14015                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14016                 nextCharPos = curSel.iCursorPos;        
       
 14017                 hindibackspace = ETrue;
       
 14018                 }
       
 14019             else
       
 14020                 {
       
 14021             nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 14022                 }   
       
 14023             }
       
 14024         }
       
 14025 
       
 14026     if ( !nextPositionFound && !hindibackspace )
       
 14027         {
       
 14028         aComsumeKey = EFalse;
       
 14029         return EFalse;
       
 14030         }
       
 14031 
       
 14032     TInt anchorPos = 0;
       
 14033     TInt cursorPos = 0;
       
 14034     TTmDocPosSpec pos = DocPos();
       
 14035     CTmTextLayout::TTmChunkDescription leftChunk;
       
 14036     CTmTextLayout::TTmChunkDescription rightChunk;
       
 14037     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 14038 
       
 14039     if (( naviEvent == ELeftNaviEvent && leftChunk.iRightToLeft ) ||
       
 14040         ( naviEvent == ERightNaviEvent && !rightChunk.iRightToLeft ))
       
 14041         {
       
 14042         anchorPos = nextCharPos;
       
 14043         cursorPos = nextCharPos;
       
 14044         FindEndOfWord(cursorPos);
       
 14045         }
       
 14046     else
       
 14047         {
       
 14048         if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14049                 (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14050             {
       
 14051             cursorPos = nextCharPos;
       
 14052             }
       
 14053         else
       
 14054             {
       
 14055             cursorPos = nextCharPos + 1;    
       
 14056             }
       
 14057         anchorPos = nextCharPos;
       
 14058         FindStartOfWord(anchorPos);
       
 14059         }
       
 14060         
       
 14061 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 14062 	TCursorSelection curSel;
       
 14063     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14064     // if selection happens dont consume the event pass it to editor
       
 14065     if((naviEvent == EBackspaceEvent)
       
 14066             && (!IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
 14067             && (curSel.iAnchorPos != curSel.iCursorPos))
       
 14068         {
       
 14069         aComsumeKey = EFalse;
       
 14070         return EFalse;
       
 14071         }
       
 14072 #endif
       
 14073 
       
 14074     iUncommittedText.SetSelection(cursorPos, anchorPos);
       
 14075 
       
 14076     if (iUncommittedText.Length() <= EMaximumFepWordLength)
       
 14077         {
       
 14078         iInputCapabilities.FepAwareTextEditor()->
       
 14079             GetEditorContentForFep(aText, iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
 14080         aComsumeKey = ETrue;
       
 14081         return ETrue;
       
 14082         }
       
 14083     else
       
 14084         {
       
 14085         if (naviEvent == EBackspaceEvent)
       
 14086             {
       
 14087             // delete the last character
       
 14088             cursorPos--;
       
 14089             iUncommittedText.SetSelection(cursorPos, cursorPos);
       
 14090             aComsumeKey = EFalse;
       
 14091             }
       
 14092         else
       
 14093             {
       
 14094             TInt newCursorPosition= (pos.iPos == cursorPos) ? anchorPos : cursorPos;
       
 14095             iUncommittedText.SetSelection(newCursorPosition, newCursorPosition);
       
 14096             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14097             aComsumeKey = ETrue;
       
 14098             }
       
 14099         // The word is longer than EMaximumFepWordLength. Ui is deactivated.
       
 14100         TryCloseUiL();
       
 14101         return EFalse;
       
 14102         }
       
 14103     }
       
 14104 
       
 14105 
       
 14106 TBool CAknFepManager::TryGetTextToUncommitL(TDes& aText, TBool& aComsumeKey)
       
 14107     {
       
 14108     TInt nextCharRightPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 14109     TInt nextCharLeftPos = 0; 
       
 14110     TBool nextRightPosFound = EFalse;
       
 14111     TBool nextLeftPosFound = EFalse;
       
 14112     
       
 14113     nextRightPosFound = GetNextVisualRightCharacter( nextCharRightPos );
       
 14114     if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) || 
       
 14115             (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14116         {
       
 14117         FindStartOfWord(nextCharRightPos);   
       
 14118                     
       
 14119         if(nextCharRightPos < iUncommittedText.LowerPos())
       
 14120             {
       
 14121             nextCharRightPos = iUncommittedText.LowerPos();
       
 14122             }
       
 14123         }
       
 14124     
       
 14125     
       
 14126     nextLeftPosFound = GetNextVisualLeftCharacter( nextCharLeftPos );
       
 14127     if( nextLeftPosFound && (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14128             (nextLeftPosFound && (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai)))
       
 14129         {
       
 14130         FindEndOfWord(nextCharLeftPos);
       
 14131         if(nextCharLeftPos > iUncommittedText.HigherPos())
       
 14132             {
       
 14133             nextCharLeftPos = iUncommittedText.HigherPos();
       
 14134             }
       
 14135         }
       
 14136             
       
 14137 
       
 14138 
       
 14139 
       
 14140     if ( !nextRightPosFound && !nextLeftPosFound )
       
 14141         {
       
 14142         aComsumeKey = EFalse;
       
 14143         return EFalse;
       
 14144         }
       
 14145 
       
 14146     TInt anchorPos = 0;
       
 14147     TInt cursorPos = 0;
       
 14148 
       
 14149     
       
 14150     
       
 14151     TTmDocPosSpec pos = DocPos();
       
 14152     CTmTextLayout::TTmChunkDescription leftChunk;
       
 14153     CTmTextLayout::TTmChunkDescription rightChunk;
       
 14154     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 14155 
       
 14156     /*
       
 14157     if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14158             (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14159         {
       
 14160         cursorPos = pos.iPos;
       
 14161         }
       
 14162     else
       
 14163         {
       
 14164         cursorPos = pos.iPos + 1;    
       
 14165         }
       
 14166     */
       
 14167     
       
 14168     anchorPos = pos.iPos;
       
 14169     cursorPos = pos.iPos;
       
 14170     FindEndOfWord(cursorPos);          
       
 14171     FindStartOfWord(anchorPos);
       
 14172     
       
 14173     
       
 14174     if(cursorPos == pos.iPos || anchorPos == pos.iPos)
       
 14175         {
       
 14176         iUncommittedText.SetSelection(pos.iPos, pos.iPos);
       
 14177         aComsumeKey = ETrue;
       
 14178         return EFalse;
       
 14179         }
       
 14180     else
       
 14181         {
       
 14182         iUncommittedText.SetSelection(cursorPos, anchorPos);
       
 14183         }  
       
 14184     
       
 14185     if (iUncommittedText.Length() <= EMaximumFepWordLength)
       
 14186         {
       
 14187         iInputCapabilities.FepAwareTextEditor()->
       
 14188             GetEditorContentForFep(aText, iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
 14189         aComsumeKey = ETrue;
       
 14190         return ETrue;
       
 14191         }
       
 14192     else
       
 14193         {
       
 14194         /*
       
 14195         TInt newCursorPosition= (pos.iPos == cursorPos) ? anchorPos : cursorPos;
       
 14196         iUncommittedText.SetSelection(newCursorPosition, newCursorPosition);
       
 14197         iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14198         */
       
 14199         aComsumeKey = ETrue;
       
 14200         // The word is longer than EMaximumFepWordLength. Ui is deactivated.
       
 14201         TryCloseUiL();
       
 14202         return EFalse;
       
 14203         }
       
 14204     }
       
 14205 
       
 14206 void CAknFepManager::UpdateCbaL(TInt aResourceId)
       
 14207     {
       
 14208     if ( !IsFepAwareTextEditor() )
       
 14209         {
       
 14210         return;
       
 14211         }
       
 14212 
       
 14213     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateCopy | ECcpuStateStartCut | ECcpuStateCut))
       
 14214         {
       
 14215         return;
       
 14216         }
       
 14217     
       
 14218     //For bug ESSG-7RXC96
       
 14219     if((iAknEditorFlags & EAknEditorFlagFindPane)&& IsChineseInputLanguage()&& aResourceId != NULL)
       
 14220         {
       
 14221         return;
       
 14222         }
       
 14223 
       
 14224 	iUiInterface->UpdateSoftkeysL(aResourceId, EditorState(), this, 
       
 14225                                 iSharedDataInterface->InputMode());
       
 14226     }
       
 14227 
       
 14228 
       
 14229 TBool CAknFepManager::TryRemoveNoMatchesIndicatorL()
       
 14230     {
       
 14231     __ASSERT_DEBUG(IsFlagSet(EFlagInsideInlineEditingTransaction), 
       
 14232                    AknFepPanic(EAknFepPanicNotInsideInlineEdit));
       
 14233 
       
 14234     if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 14235         {
       
 14236         ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 14237         TBuf<EMaximumFepWordLength> newText;
       
 14238         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
 14239                                                                       iUncommittedText.iAnchorPos,
       
 14240                                                                       iUncommittedText.Length());
       
 14241         iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(newText, 
       
 14242                                                                       iUncommittedText.Length());
       
 14243         SendEventsToPluginManL( EPluginSyncFepAwareText );
       
 14244         return ETrue;
       
 14245         }
       
 14246     return EFalse;
       
 14247     }
       
 14248 
       
 14249 TBool CAknFepManager::IsMoreGoodWordsComing(TInt aNewWordLength) const
       
 14250     {
       
 14251     return (aNewWordLength == iUncommittedText.Length() + 1);
       
 14252     }
       
 14253 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 14254 TBool CAknFepManager::IsMoreGoodAutoCompleteWordsComing(TInt aInputMode,TInt aPreviousWordLength, 
       
 14255                                                         TInt aNewWordLength) const
       
 14256 	{
       
 14257 	return ((aInputMode == EPtiEngineWordCompletion) && (aPreviousWordLength != aNewWordLength ));	
       
 14258 	}
       
 14259 #endif
       
 14260 
       
 14261 void CAknFepManager::TryStartCompoundWord()
       
 14262     {
       
 14263     // check if this word constitutes a 'compound' word
       
 14264     // i.e. is either adjacent char is an alphabetic characeter
       
 14265     TBuf<ESingleCharacter> ch;
       
 14266     // check the previous character
       
 14267     if(iUncommittedText.iAnchorPos>0)
       
 14268         {
       
 14269         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(ch, 
       
 14270                                                                      iUncommittedText.iAnchorPos-1,
       
 14271                                                                      ESingleCharacter);
       
 14272         if (ch.Length()>0 && STATIC_CAST(TChar, IsValidInLineCharacter(ch[0])))
       
 14273             {
       
 14274             SetFlag(EFlagCompoundWord);
       
 14275             }
       
 14276         }
       
 14277 
       
 14278     // check the next character
       
 14279     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 14280     if (!IsFlagSet(EFlagCompoundWord) && iUncommittedText.iAnchorPos < edSize)
       
 14281         {
       
 14282         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(ch, 
       
 14283                                                                      iUncommittedText.iAnchorPos,
       
 14284                                                                      ESingleCharacter);
       
 14285         if (ch.Length()>0 && STATIC_CAST(TChar, IsValidInLineCharacter(ch[0])))
       
 14286             {
       
 14287             SetFlag(EFlagCompoundWord);
       
 14288             }
       
 14289         }
       
 14290     }
       
 14291 
       
 14292 void CAknFepManager::AddCompoundWordToUdbL()
       
 14293     {
       
 14294     __ASSERT_DEBUG(WesternPredictive() , AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 14295 
       
 14296     HBufC* compoundWordBuf = 
       
 14297                    HBufC::NewLC(iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep()); // buffer for text
       
 14298     TPtr compoundWord=compoundWordBuf->Des();
       
 14299 
       
 14300     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14301 
       
 14302     // reset cursor span on word
       
 14303     FindStartOfWord(iUncommittedText.iAnchorPos);
       
 14304     FindEndOfWord(iUncommittedText.iCursorPos);
       
 14305 
       
 14306     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(compoundWord, 
       
 14307                                                                     iUncommittedText.iAnchorPos, 
       
 14308                                                                     iUncommittedText.Length());
       
 14309     FepUI()->AddTextToUserDictionaryL(compoundWord);
       
 14310     CleanupStack::PopAndDestroy();  // compoundWordBuf
       
 14311     }
       
 14312 
       
 14313 void CAknFepManager::SetWesternPredictive( const TBool aWesternPredictive )
       
 14314     {
       
 14315     const TInt previousValue = iWesternPredictive;
       
 14316     iWesternPredictive = aWesternPredictive && !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
 14317     // Predictive QWERTY (XT9) changes ---->
       
 14318         (   
       
 14319 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14320         (
       
 14321 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14322 		iLanguageCapabilities.iSupportsWesternPredictive 
       
 14323 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14324         && !iQwertyInputMode)
       
 14325          || (iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode) 
       
 14326 #ifdef __HALF_QWERTY_KEYPAD
       
 14327          || (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive && iQwertyInputMode) 
       
 14328 #endif //__HALF_QWERTY_KEYPAD
       
 14329 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14330 		);
       
 14331     // Predictive QWERTY (XT9) changes <----
       
 14332     if ( (previousValue != iWesternPredictive) && !(iAknEditorFlags & EAknEditorFlagNoT9) )
       
 14333         {
       
 14334         if (iWesternPredictive)
       
 14335             {
       
 14336             iSharedDataInterface->SetPredictiveTextOn();
       
 14337             }
       
 14338         else
       
 14339             {
       
 14340             iSharedDataInterface->ResetPredictiveTextOn();
       
 14341             }
       
 14342         }
       
 14343     }
       
 14344 
       
 14345 void CAknFepManager::SetWesternAutoComplete( const TBool aWesternAutoComplete )
       
 14346     {
       
 14347     const TInt previousValue = iIsAutoCompleteOn;
       
 14348     iIsAutoCompleteOn = aWesternAutoComplete && !(iAknEditorFlags & EAknEditorFlagNoT9);
       
 14349     if ( (previousValue != iIsAutoCompleteOn) && !(iAknEditorFlags & EAknEditorFlagNoT9) )
       
 14350         {
       
 14351         if (iIsAutoCompleteOn)
       
 14352             {
       
 14353             iSharedDataInterface->SetPredictiveTextAutoCompleteOn();
       
 14354             }
       
 14355         else
       
 14356             {
       
 14357             iSharedDataInterface->ResetPredictiveTextAutoCompleteOn();
       
 14358             }
       
 14359         }
       
 14360     }
       
 14361 
       
 14362 void CAknFepManager::SetJapanesePredictive(const TBool aJapanesePredictive)
       
 14363     {
       
 14364     if (iJapanesePredictive != aJapanesePredictive)
       
 14365         {
       
 14366         iJapanesePredictive = aJapanesePredictive;
       
 14367         }
       
 14368     if (iJapanesePredictive & iSharedDataInterface->PredictiveTextJapaneseOn()
       
 14369      || !iJapanesePredictive & !iSharedDataInterface->PredictiveTextJapaneseOn())
       
 14370         {
       
 14371         if(iJapanesePredictive)
       
 14372             {
       
 14373             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
 14374             }
       
 14375         else
       
 14376             {
       
 14377             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 14378             }
       
 14379         }
       
 14380     }
       
 14381 
       
 14382 void CAknFepManager::SetQwertyMode(const TBool aQwertyInputMode)
       
 14383     {
       
 14384 #ifdef RD_SCALABLE_UI_V2
       
 14385     if( aQwertyInputMode && iFepPluginManager && 
       
 14386         iSharedDataInterface->PluginInputMode() != EPluginInputModeNone
       
 14387         // Add this condition for addtion of ITI features on FSQ.
       
 14388         // iSharedDataInterface->QwertyInputMode() == 1, means that 
       
 14389         // hw keyboard is slided, then need to close touch inputmethods.
       
 14390         && iSharedDataInterface->QwertyInputMode() )
       
 14391         {
       
 14392         iFepPluginManager->ResetMenuState(EFalse);        
       
 14393         ExitPluginSpellModeByCancel();
       
 14394         TRAP_IGNORE(iFepPluginManager->ClosePluginInputModeL( ETrue ));
       
 14395         if ( iCancelPopupInQwerty )
       
 14396             {
       
 14397             TRAP_IGNORE( SimulateKeyEventL( EKeyCBA2 ) );
       
 14398             }
       
 14399         }
       
 14400     SetQwertyModeToInputcapbility();
       
 14401 #endif//RD_SCALABLE_UI_V2
       
 14402     if (!COMPARE_BOOLS(aQwertyInputMode, iQwertyInputMode))
       
 14403         {
       
 14404 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 14405         if(IsAutoCompleteOn())
       
 14406         	{
       
 14407             TRAP_IGNORE(RemoveSuggestedCompletionL());
       
 14408             }
       
 14409 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14410         iQwertyInputMode = aQwertyInputMode;
       
 14411         if (!iQwertyInputMode)
       
 14412             {
       
 14413 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14414             SetTypingCorrectionLevel(EPtiErrorCorrectionLevelHigh);
       
 14415             SetNumberCandidateState(ETrue); // ETrue
       
 14416             SetPrimaryCandidate(EFalse); // Best prediction
       
 14417 #endif            
       
 14418             ClearFlag(EFlagQwertyShiftMode | EFlagNoActionDuringChrKeyPress);
       
 14419             }
       
 14420 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14421         else
       
 14422 	        {
       
 14423 	        iSharedDataInterface->HandlePredictiveTextNumberCandidateSettingChange();
       
 14424 	        iSharedDataInterface->HandlePredictiveTextTypingCorrectionLevelChange();
       
 14425 	        iSharedDataInterface->HandlePredictiveTextPrimaryCandidateChange();	
       
 14426 	        }
       
 14427 #endif        
       
 14428 
       
 14429         if ( iFepManState != EAknFepStateNull && IsFepAwareTextEditor() )
       
 14430             {
       
 14431 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14432 
       
 14433 			   // In case of layout remove the auto completion part
       
 14434 			   // Before transfer fep state to editor state.        
       
 14435                if(IsAutoCompleteOn())
       
 14436             	{
       
 14437 #ifdef RD_SCALABLE_UI_V2            	
       
 14438                 if( iFepPluginManager 
       
 14439                         && iFepPluginManager->IsSupportITIOnFSQ()
       
 14440                         && !iQwertyInputMode )
       
 14441                     {
       
 14442                     TRAP_IGNORE( iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate ) );
       
 14443                     }
       
 14444                 else
       
 14445 #endif //RD_SCALABLE_UI_V2                	
       
 14446                     {
       
 14447                     TInt tailLength = 0;
       
 14448                     TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 14449                     if(tailLength > 0)
       
 14450                         {
       
 14451                         TRAP_IGNORE(
       
 14452                             {
       
 14453                             RemoveSuggestedAdvanceCompletionL();
       
 14454                             iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );
       
 14455                             });                       
       
 14456                         }
       
 14457                     }
       
 14458             	}
       
 14459 #endif 
       
 14460             if ( !iFocusedItemDestroy )
       
 14461             	{            	
       
 14462                 TRAP_IGNORE(
       
 14463                     {
       
 14464                     TransferFepStateToEditorL();
       
 14465                     TryCloseUiL();
       
 14466                     ConfigureFEPFromEditorStateL();
       
 14467                     });                
       
 14468             	}            
       
 14469             }
       
 14470         }
       
 14471 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14472     if(iFnKeyManager)
       
 14473         iFnKeyManager->SetQwertyInputMode(aQwertyInputMode);
       
 14474 #endif
       
 14475     }
       
 14476 
       
 14477 TBool CAknFepManager::WesternPredictive(TInt aMode) const
       
 14478     {
       
 14479     TInt mode = iMode;
       
 14480     if ( aMode )
       
 14481         {
       
 14482         mode = aMode;
       
 14483         }
       
 14484     return (mode == ELatin && iWesternPredictive &&
       
 14485     // Predictive QWERTY (XT9) changes ---->
       
 14486       
       
 14487 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14488         ((
       
 14489 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14490 		iLanguageCapabilities.iSupportsWesternPredictive 
       
 14491 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14492         && !iQwertyInputMode)
       
 14493          || (iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode)
       
 14494 #ifdef __HALF_QWERTY_KEYPAD
       
 14495 		|| (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive && iQwertyInputMode)
       
 14496 #endif //__HALF_QWERTY_KEYPAD
       
 14497 		)
       
 14498 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14499 		);
       
 14500     // Predictive QWERTY (XT9) changes <----
       
 14501     }
       
 14502 
       
 14503 TBool CAknFepManager::IsPredictive(TInt aMode) const
       
 14504     {
       
 14505     TBool isPredictive = EFalse;
       
 14506     TInt mode = iMode;
       
 14507     if ( aMode )
       
 14508         {
       
 14509         mode = aMode;
       
 14510         }
       
 14511     if (mode == EHiraganaKanji )
       
 14512         {
       
 14513         if ((iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
 14514          && iJapanesePredictive
       
 14515          && !(iAknEditorFlags & EAknEditorFlagNoT9)
       
 14516          && HasJapanesePredictionInputMode())
       
 14517             {
       
 14518             isPredictive = ETrue;
       
 14519             // Japanese predictive input is available on both Qwerty and not Qwerty
       
 14520             return isPredictive;
       
 14521             }
       
 14522         }
       
 14523     else if (mode == ELatin)
       
 14524         {
       
 14525         if ((iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorHalfWidthTextInputMode))
       
 14526           && !(iAknEditorFlags & EAknEditorFlagNoT9)
       
 14527           && iWesternPredictive && 
       
 14528           (iLanguageCapabilities.iSupportsWesternPredictive
       
 14529 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14530            ||iLanguageCapabilities.iSupportsWesternQwertyPredictive 
       
 14531 #ifdef __HALF_QWERTY_KEYPAD           
       
 14532            ||iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive
       
 14533 #endif //__HALF_QWERTY_KEYPAD           
       
 14534 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14535 		)) // Predictive QWERTY (XT9) changes
       
 14536             {
       
 14537             isPredictive = ETrue;
       
 14538             }
       
 14539         }
       
 14540 #ifdef RD_SCALABLE_UI_V2
       
 14541 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14542 	    return isPredictive; //&& (iFepPluginManager->PluginInputMode() == EPluginInputModeNone);
       
 14543 	#else
       
 14544 	    return isPredictive && !iQwertyInputMode 
       
 14545              && ((iFepPluginManager->PluginInputMode() == EPluginInputModeItut) 
       
 14546 	    			|| (iFepPluginManager->PluginInputMode() == EPluginInputModeNone));
       
 14547 	#endif //RD_INTELLIGENT_TEXT_INPUT
       
 14548 #else
       
 14549 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14550 	    return isPredictive;
       
 14551 	#else
       
 14552 	    return isPredictive && !iQwertyInputMode;
       
 14553 	#endif //RD_INTELLIGENT_TEXT_INPUT
       
 14554 #endif //RD_SCALABLE_UI_V2
       
 14555     }
       
 14556 
       
 14557 TBool CAknFepManager::Japanese() const
       
 14558     {
       
 14559     TBool rtn = EFalse;
       
 14560     switch (iMode)
       
 14561         {
       
 14562         case EHiraganaKanji:
       
 14563         case EKatakana:
       
 14564         case EHiragana:
       
 14565             rtn = ETrue;
       
 14566             break;
       
 14567         case ELatin:
       
 14568             if ((!WesternPredictive()) && iCharWidth == EFullWidthChar)
       
 14569                 {
       
 14570                 rtn = ETrue;
       
 14571                 }
       
 14572             break;
       
 14573         case ENumber:
       
 14574             if (iCharWidth == EFullWidthChar)
       
 14575                 {
       
 14576                 rtn = ETrue;
       
 14577                 }
       
 14578             break;
       
 14579         default:
       
 14580             break;
       
 14581         }
       
 14582     return rtn;
       
 14583     }
       
 14584 
       
 14585 TBool CAknFepManager::IsOnlyFullWidthCharacterPermitted() const
       
 14586     {
       
 14587     CAknEdwinState* editorState = EditorState();
       
 14588     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14589     TUint fullWidthPermitted = (EAknEditorFullWidthTextInputMode
       
 14590                               | EAknEditorFullWidthNumericInputMode
       
 14591                               | EAknEditorFullWidthKatakanaInputMode);
       
 14592     TUint fullWidthNotPermitted = ~fullWidthPermitted;
       
 14593     TBool isfullchar = ETrue;
       
 14594     if (permittedInputModes & fullWidthNotPermitted)
       
 14595         {
       
 14596         isfullchar = EFalse;
       
 14597         }
       
 14598 
       
 14599     if (!(permittedInputModes & fullWidthPermitted))
       
 14600         {
       
 14601         isfullchar = EFalse;
       
 14602         }
       
 14603 
       
 14604     return isfullchar;
       
 14605     }
       
 14606 
       
 14607 TBool CAknFepManager::IsOnlyHalfWidthCharacterPermitted() const
       
 14608     {
       
 14609     CAknEdwinState* editorState = EditorState();
       
 14610     TUint permittedInputModes;
       
 14611     if( editorState )
       
 14612         {
       
 14613         permittedInputModes= editorState->PermittedInputModes();
       
 14614         }
       
 14615     else
       
 14616         {
       
 14617         permittedInputModes = EAknEditorNumericInputMode;
       
 14618         }
       
 14619     TUint halfWidthNotPermitted = (EAknEditorFullWidthTextInputMode
       
 14620                                  | EAknEditorFullWidthNumericInputMode
       
 14621                                  | EAknEditorFullWidthKatakanaInputMode
       
 14622                                  | EAknEditorHiraganaKanjiInputMode
       
 14623                                  | EAknEditorHiraganaInputMode);
       
 14624 
       
 14625     TUint halfWidthPermitted  = ~halfWidthNotPermitted;
       
 14626     TBool ishalfchar = ETrue;
       
 14627     if (permittedInputModes & halfWidthNotPermitted)
       
 14628         {
       
 14629         ishalfchar = EFalse;
       
 14630         }
       
 14631 
       
 14632     if (!(permittedInputModes & halfWidthPermitted))
       
 14633         {
       
 14634         ishalfchar = EFalse;
       
 14635         }
       
 14636     if (permittedInputModes & EAknEditorTextInputMode)
       
 14637         {
       
 14638         ishalfchar = EFalse;
       
 14639         }
       
 14640     if (editorState && (editorState->Flags() & EAknEditorFlagLatinInputModesOnly))
       
 14641         {
       
 14642         ishalfchar = ETrue;
       
 14643         }
       
 14644     return ishalfchar;
       
 14645     }
       
 14646 
       
 14647 TBool CAknFepManager::IsHalfAndFullKatakanaPermitted() const
       
 14648     {
       
 14649     CAknEdwinState* editorState = EditorState();
       
 14650     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14651     TUint katakanaInputMode = (EAknEditorKatakanaInputMode
       
 14652                               | EAknEditorFullWidthKatakanaInputMode);
       
 14653     TBool iskatakana = EFalse;
       
 14654     if ((permittedInputModes & katakanaInputMode) == katakanaInputMode)
       
 14655         {
       
 14656         iskatakana = ETrue;
       
 14657         }
       
 14658     return iskatakana;
       
 14659     }
       
 14660 
       
 14661 TBool CAknFepManager::IsHalfAndFullLatinPermitted() const
       
 14662     {
       
 14663     CAknEdwinState* editorState = EditorState();
       
 14664     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14665     TUint latinInputMode = (EAknEditorHalfWidthTextInputMode
       
 14666                               | EAknEditorFullWidthTextInputMode);
       
 14667     TBool islatin = EFalse;
       
 14668 
       
 14669     if ((permittedInputModes & latinInputMode) == latinInputMode)
       
 14670         {
       
 14671         islatin = ETrue;
       
 14672         }
       
 14673     return islatin;
       
 14674     }
       
 14675 
       
 14676 TBool CAknFepManager::IsHalfAndFullNumberPermitted() const
       
 14677     {
       
 14678     CAknEdwinState* editorState = EditorState();
       
 14679     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14680     TUint numInputMode = (EAknEditorNumericInputMode
       
 14681                               | EAknEditorFullWidthNumericInputMode);
       
 14682     TBool isnum = EFalse;
       
 14683     if ((permittedInputModes & numInputMode) == numInputMode)
       
 14684         {
       
 14685         isnum = ETrue;
       
 14686         }
       
 14687 
       
 14688     return isnum;
       
 14689     }
       
 14690 
       
 14691 TWidthChar CAknFepManager::CharacterWidth() const
       
 14692     {
       
 14693     return iCharWidth;
       
 14694     }
       
 14695 
       
 14696 CPtiEngine* CAknFepManager::PtiEngine() const
       
 14697     {
       
 14698     return iPtiEngine;
       
 14699     }
       
 14700 
       
 14701 void CAknFepManager::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
       
 14702     {
       
 14703 #ifdef RD_SCALABLE_UI_V2
       
 14704     if ( SemiFepAwareTextEditor( ETrue ) )
       
 14705 #else
       
 14706     if (iInputCapabilities.FepAwareTextEditor())
       
 14707 #endif // RD_SCALABLE_UI_V2
       
 14708         {
       
 14709         iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(aCursorVisibility);
       
 14710         }
       
 14711     }
       
 14712 
       
 14713 TInt CAknFepManager::InputMode() const
       
 14714     {
       
 14715     return iMode;
       
 14716     }
       
 14717     
       
 14718 TInt CAknFepManager::CangJieMode() const
       
 14719     {
       
 14720     TInt shareMode = iSharedDataInterface->CangJieMode();
       
 14721     TInt cangjieMode = shareMode + EPtiEngineNormalCangjieQwerty;
       
 14722     return cangjieMode;
       
 14723     }    
       
 14724 
       
 14725 TBool CAknFepManager::InputLanguageSupportsCaseChanges() const
       
 14726     {
       
 14727     return iLanguageCapabilities.iSupportsCase;
       
 14728     }
       
 14729 
       
 14730 TBool CAknFepManager::IsAbleScrollLatinPredictive() const
       
 14731     {
       
 14732     return iSharedDataInterface->ScrollLatinPredictiveCandidates();
       
 14733     }
       
 14734 
       
 14735 TText CAknFepManager::PreviousChar( TBool /*aContextSensitive*/ )
       
 14736     {
       
 14737     TBuf<ESingleCharacter> previousCharacter(ESingleCharacter);
       
 14738     previousCharacter.FillZ();
       
 14739 
       
 14740     TCursorSelection curSel;
       
 14741     if ( IsFepAwareTextEditor() )
       
 14742         {
       
 14743         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14744         TInt lowerpos = curSel.LowerPos();
       
 14745         if(lowerpos > 0)
       
 14746             {
       
 14747             iInputCapabilities.FepAwareTextEditor()->
       
 14748                 GetEditorContentForFep(previousCharacter, lowerpos-1, ESingleCharacter);
       
 14749             if (previousCharacter.Length())
       
 14750                 return previousCharacter[0];
       
 14751             }
       
 14752         }
       
 14753     return NULL;
       
 14754     }
       
 14755 
       
 14756 TBool CAknFepManager::IsZWSCharacterPresent( TBool aLigaturePresent /* = EFalse*/ )
       
 14757     {
       
 14758     TBuf<3> previousCharacter;
       
 14759     previousCharacter.Zero();
       
 14760     TBool found = EFalse;
       
 14761     previousCharacter.FillZ();
       
 14762 
       
 14763     TCursorSelection curSel;
       
 14764     if ( IsFepAwareTextEditor() )
       
 14765         {
       
 14766         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 14767             iInputCapabilities.FepAwareTextEditor();
       
 14768         fepAwareTextEditor->GetCursorSelectionForFep(curSel);
       
 14769         TInt lowerpos = curSel.LowerPos();
       
 14770         if( lowerpos > 1 )
       
 14771             {
       
 14772             if( aLigaturePresent && lowerpos > 3 )
       
 14773                 {
       
 14774                 fepAwareTextEditor->
       
 14775                     GetEditorContentForFep(previousCharacter, 
       
 14776                                             lowerpos - 4, 2);
       
 14777                 }
       
 14778             else
       
 14779                 {
       
 14780                 fepAwareTextEditor->
       
 14781                     GetEditorContentForFep(previousCharacter, 
       
 14782                                             lowerpos - 2, 2);
       
 14783                 }
       
 14784             if( previousCharacter[0] == ZERO_WIDTH_SPACE
       
 14785                      || previousCharacter[1] == ZERO_WIDTH_SPACE )
       
 14786                 {
       
 14787                 found = ETrue;
       
 14788                 }   
       
 14789             }
       
 14790         }
       
 14791     return found;
       
 14792     }
       
 14793 
       
 14794 TText CAknFepManager::NextChar()    
       
 14795     {
       
 14796     TBuf<ESingleCharacter> nextCharacter(ESingleCharacter);
       
 14797     nextCharacter.FillZ();
       
 14798 
       
 14799     TCursorSelection curSel;
       
 14800     if ( IsFepAwareTextEditor() )
       
 14801         {
       
 14802         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14803         TInt higherpos = curSel.HigherPos();
       
 14804         TInt maxLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 14805         if ( higherpos >= 0 && higherpos <= maxLength && maxLength >= 1 ) 
       
 14806             {
       
 14807             iInputCapabilities.FepAwareTextEditor()->
       
 14808                 GetEditorContentForFep(nextCharacter, higherpos, ESingleCharacter);
       
 14809             if( nextCharacter.Length() )    
       
 14810                 return nextCharacter[0];
       
 14811             }
       
 14812         }
       
 14813     return NULL;    
       
 14814     }
       
 14815     
       
 14816 void CAknFepManager::FindStartOfWord(TInt& aAnchorPos) const
       
 14817     {
       
 14818     TBuf<ESingleCharacter> characterBuffer;
       
 14819     FOREVER
       
 14820         {
       
 14821         if (aAnchorPos<=0)
       
 14822             {
       
 14823             break; // start of editor
       
 14824             }
       
 14825         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 14826                                                                         aAnchorPos-1, 
       
 14827                                                                         ESingleCharacter);
       
 14828         if (!IsValidInLineCharacter(characterBuffer[0]))
       
 14829             {
       
 14830             break;
       
 14831             }
       
 14832         aAnchorPos--;
       
 14833         }
       
 14834     }
       
 14835 
       
 14836 void CAknFepManager::FindEndOfWord(TInt& aCursorPos) const
       
 14837     {
       
 14838     TBuf<ESingleCharacter> characterBuffer;
       
 14839     FOREVER
       
 14840         {
       
 14841         if (aCursorPos>=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
 14842             {
       
 14843             break; // end of editor
       
 14844             }
       
 14845         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 14846                                                                         aCursorPos, 
       
 14847                                                                         ESingleCharacter);
       
 14848         if (!IsValidInLineCharacter(characterBuffer[0]))
       
 14849             {
       
 14850             break;
       
 14851             }
       
 14852         aCursorPos++;
       
 14853         }
       
 14854     }
       
 14855 
       
 14856 TBool CAknFepManager::CursorInsideWord()
       
 14857     {
       
 14858     TBuf<ESingleCharacter> characterBuffer;
       
 14859     TBool insideWord=ETrue;
       
 14860 
       
 14861     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14862     TInt cursorPos=iUncommittedText.iCursorPos;
       
 14863 
       
 14864     if (cursorPos)
       
 14865         {
       
 14866         // check character before cursor
       
 14867         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 14868                                                                         cursorPos-1, 
       
 14869                                                                         ESingleCharacter);
       
 14870         if (characterBuffer.Length())
       
 14871 			{
       
 14872             if (!IsValidInLineCharacter(characterBuffer[0]))
       
 14873                 {
       
 14874                 insideWord=EFalse;
       
 14875                 }
       
 14876 			}	
       
 14877         }
       
 14878     else // at start of editor
       
 14879         {
       
 14880         insideWord=EFalse;
       
 14881         }
       
 14882 
       
 14883     if (insideWord && cursorPos<iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
 14884         {
       
 14885         // put character after cursor into buffer
       
 14886         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, cursorPos,
       
 14887                                                                         ESingleCharacter);
       
 14888         if (characterBuffer.Length())
       
 14889 			{
       
 14890             if (!IsValidInLineCharacter(characterBuffer[0]))
       
 14891                 {
       
 14892                 insideWord=EFalse;
       
 14893                 }
       
 14894 			}	
       
 14895         }
       
 14896     else // at end of editor
       
 14897         {
       
 14898         insideWord=EFalse;
       
 14899         }
       
 14900 
       
 14901     return insideWord;
       
 14902     }
       
 14903 
       
 14904 void CAknFepManager::MoveCursorToStartOfWordL()
       
 14905     {
       
 14906     TInt anchorPos=iUncommittedText.iAnchorPos;
       
 14907     FindStartOfWord(anchorPos);
       
 14908     iUncommittedText.SetSelection(anchorPos, anchorPos);
       
 14909     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14910     }
       
 14911 
       
 14912 void CAknFepManager::MoveCursorToEndOfWordL()
       
 14913     {
       
 14914     TInt cursorPos=iUncommittedText.iCursorPos;
       
 14915     
       
 14916     if(!IsExtendedFlagSet(EExtendedFlagOkKeyPressOnCandidatePopup))    
       
 14917     	FindEndOfWord(cursorPos);
       
 14918     iUncommittedText.SetSelection(cursorPos, cursorPos);
       
 14919     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14920     }
       
 14921 
       
 14922 TKeyResponse CAknFepManager::HandleNaviEventOutsideInlineEditL(TUint aCode, 
       
 14923                                                                TKeyPressLength aLength)
       
 14924     {
       
 14925     TKeyResponse response = EKeyWasNotConsumed;
       
 14926 
       
 14927     if (TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response))
       
 14928         {
       
 14929         return response;
       
 14930         }
       
 14931     if (WesternPredictive())
       
 14932         {
       
 14933         response = HandlePredictiveNaviEventOutsideInlineEditL(aCode, aLength);
       
 14934         }
       
 14935 
       
 14936     return response;
       
 14937     }
       
 14938 
       
 14939 TKeyResponse CAknFepManager::HandleWesternPredictiveArrowKeyL(TInt aCode, TKeyPressLength aLength)
       
 14940     {
       
 14941     TKeyResponse response = EKeyWasNotConsumed;
       
 14942     
       
 14943     if (IsFlagSet(EFlagLineFeedCharacter))
       
 14944         {
       
 14945         // This event will stop the multitapping timer for enter chr.
       
 14946         // just return.
       
 14947         return EKeyWasConsumed;                
       
 14948         }
       
 14949 
       
 14950 	TCursorSelection selection;
       
 14951     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 14952     if(!IsMfneEditor() &&
       
 14953          ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut) &&
       
 14954          selection.Length() > 0)
       
 14955         {
       
 14956         // If open virtual ITUT and highlight some chars
       
 14957         return EKeyWasConsumed;
       
 14958         }        
       
 14959     if (aCode == EKeyUpArrow || aCode == EKeyDownArrow)
       
 14960         {
       
 14961         ClearFlag(EFlagCompoundWord);
       
 14962         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 14963             {
       
 14964             // moving out of an inline edit
       
 14965             TryRemoveNoMatchesIndicatorL();
       
 14966             UpdateCbaL(NULL);
       
 14967             // To rip off suggested word completion when user presses UP / DOWN arrow keys
       
 14968             if(IsAutoCompleteOn())
       
 14969            		{
       
 14970 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 14971            		
       
 14972            		RemoveSuggestedCompletionL();
       
 14973            		
       
 14974 #else
       
 14975            		TInt tailLength = 0;
       
 14976            		iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
 14977 										&tailLength );
       
 14978            		if(tailLength > 0)
       
 14979            			{
       
 14980            			RemoveSuggestedAdvanceCompletionL();
       
 14981            			return EKeyWasConsumed;
       
 14982            			}
       
 14983 #endif          	
       
 14984             	}
       
 14985             if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 14986                 {
       
 14987                 CommitInlineEditL();
       
 14988                 TryCloseUiL();
       
 14989                 SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 14990                 // pass to editor for text selection.
       
 14991                 response=EKeyWasNotConsumed;
       
 14992                 }
       
 14993             }
       
 14994 		if ((iInputCapabilities.FepAwareTextEditor() && !TryHandleTextSelectedNaviEventL(aCode, response)) && !IsFlagSet(EFlagShiftKeyDepressed))
       
 14995             {
       
 14996             if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 14997                 {
       
 14998                 ClearFlag(CAknFepManager::EFlagNoMatches);
       
 14999                 TryRemoveNoMatchesIndicatorL();
       
 15000                 CommitInlineEditL();
       
 15001                 }
       
 15002             UpdateCbaL(NULL);
       
 15003 
       
 15004             // simulate a designated key event to catch and check if we're inside a word
       
 15005             if (aCode == EKeyDownArrow)
       
 15006                 {
       
 15007                 SimulateKeyEventL(EKeyF22);
       
 15008                 }
       
 15009             else
       
 15010                 {
       
 15011                 SimulateKeyEventL(EKeyF23);
       
 15012                 }
       
 15013             // pass to editor for text selection.
       
 15014             response=EKeyWasNotConsumed;
       
 15015             }
       
 15016         else if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 15017             {
       
 15018             // Need to update case indicator if text selection is made upwards.
       
 15019             SimulateKeyEventL(EKeyF19);
       
 15020             }
       
 15021         }
       
 15022     else // right or left
       
 15023         {
       
 15024         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15025             {
       
 15026             // moving out of an inline edit
       
 15027 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 15028                 if(IsAutoCompleteOn())
       
 15029                 	{
       
 15030                 	if((aCode == EKeyLeftArrow && 
       
 15031                 	    		CurrentInputDirectionality() == TBidiText::ELeftToRight) || 
       
 15032                 	    (aCode == EKeyRightArrow && 
       
 15033                 	    		CurrentInputDirectionality() == TBidiText::ERightToLeft))
       
 15034                 		{
       
 15035                 		RemoveSuggestedCompletionL();	
       
 15036                 		}
       
 15037                 	}
       
 15038 #else
       
 15039             if(IsAutoCompleteOn())
       
 15040             	{
       
 15041                 TInt tailLength = 0;
       
 15042             	iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
 15043             	// In case the inline editing is ongoing and there is a word completion
       
 15044                 // currently shown, the first backwards tap will remove the suggested 
       
 15045                 // completion. 
       
 15046                 if(tailLength > 0)
       
 15047 	                {
       
 15048 	                if (((CurrentInputDirectionality()==TBidiText::ERightToLeft) && aCode == EKeyLeftArrow) 
       
 15049 	                	|| ((CurrentInputDirectionality()==TBidiText::ELeftToRight) && aCode == EKeyRightArrow ))
       
 15050 	                    {
       
 15051 					    iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate);
       
 15052 					    TPtrC selectedWord = iPtiEngine->CurrentWord();
       
 15053                         UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
 15054                         iPtiEngine->CommitCurrentWord();
       
 15055                         TryCloseUiL();
       
 15056                         // Asyncronous case update after the editor has handled the key
       
 15057                 		SimulateKeyEventL(EKeyF19); 
       
 15058 	                    response=EKeyWasConsumed;
       
 15059 	                    }
       
 15060 	                else if(((CurrentInputDirectionality()== TBidiText::ERightToLeft ) && aCode == EKeyRightArrow) 
       
 15061 	                	|| ((CurrentInputDirectionality()== TBidiText::ELeftToRight) && aCode == EKeyLeftArrow )) 
       
 15062 		                {
       
 15063 	                    RemoveSuggestedAdvanceCompletionL();
       
 15064 	                    response=EKeyWasConsumed;
       
 15065 		                } 
       
 15066 			           return response;   	
       
 15067 	                }
       
 15068 	                else if (!IsQwerty())
       
 15069 		                {
       
 15070 		                iPtiEngine->CommitCurrentWord();
       
 15071 		                }
       
 15072 				
       
 15073             	}
       
 15074 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 15075             TryRemoveNoMatchesIndicatorL();
       
 15076             UpdateCbaL(NULL);
       
 15077             if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 15078                 {
       
 15079 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 15080                  if(IsAutoCompleteOn()) // To rip off suggested completion when shift key is pressed 
       
 15081                  	{
       
 15082                  	RemoveSuggestedCompletionL();
       
 15083                 	}
       
 15084 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15085                 CommitInlineEditL();
       
 15086                 TryCloseUiL();
       
 15087                 SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 15088                 // pass to editor for text selection.
       
 15089                 response=EKeyWasNotConsumed;
       
 15090                 }
       
 15091             else
       
 15092                 {
       
 15093                 TWesternNaviEvent naviEvent = ELeftNaviEvent;
       
 15094                 if (aCode == EKeyRightArrow)
       
 15095                     {
       
 15096                     naviEvent = ERightNaviEvent;
       
 15097                     }
       
 15098                 // Find the visual left/right end of the current word
       
 15099                 TTmDocPosSpec pos;
       
 15100                 GetAvkonDefinedVisualLimitsOfSelection(
       
 15101                     iUncommittedText, naviEvent, pos, NULL );
       
 15102 
       
 15103                 if (IsCcpuFlagSet(ECcpuStateNewPredictiveWord))
       
 15104                     {
       
 15105                     // This is new predictive word which is being committed with arrow
       
 15106                     // key. Force ::TryCloseUiL to commit PtiEngie word to keep
       
 15107                     // frequency information in sync.
       
 15108                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
 15109                     }
       
 15110 
       
 15111                 TryCloseUiL();
       
 15112 
       
 15113                 // Position should be dis-ambiguated based on last navigation and direction of blocks.
       
 15114                 AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( pos, naviEvent );
       
 15115 
       
 15116                 SetCursorPositionL( pos );
       
 15117                 if (CursorInsideWord() && naviEvent == ERightNaviEvent)
       
 15118                 {
       
 15119                     MoveCursorToEndOfWordL();
       
 15120                 }
       
 15121 
       
 15122                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15123                 response=EKeyWasConsumed;
       
 15124                 }
       
 15125             }
       
 15126         else
       
 15127             {
       
 15128 #ifndef RD_INTELLIGENT_TEXT_INPUT            
       
 15129             if ( iLanguageCapabilities.iInputLanguageCode == ELangThai ) // Without this, t9 goes inside words
       
 15130                 {                               // That is not allowed in Thai
       
 15131                 response = EKeyWasNotConsumed;
       
 15132                 }
       
 15133             else
       
 15134 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15135             response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
 15136             if (response == EKeyWasNotConsumed)
       
 15137                 {
       
 15138                 // moving over a space
       
 15139                 if (aCode == EKeyLeftArrow && !IsFlagSet(EFlagShiftKeyDepressed))
       
 15140                     {
       
 15141                     iCaseMan->UpdateCase(ELeftNaviEvent);
       
 15142                     }
       
 15143                 else if (!IsFlagSet(EFlagShiftKeyDepressed)) // EKeyRightArrow
       
 15144                     {
       
 15145                     iCaseMan->UpdateCase(ERightNaviEvent);
       
 15146                     }
       
 15147                 }
       
 15148             else
       
 15149                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15150             }
       
 15151         }
       
 15152     return response;
       
 15153     }
       
 15154 
       
 15155 TBool CAknFepManager::TryHandleTextSelectedNaviEventL(TInt aCode, TKeyResponse& response)
       
 15156     {
       
 15157     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 15158 
       
 15159     if (!IsFlagSet(EFlagShiftKeyDepressed) && iUncommittedText.Length())
       
 15160         {
       
 15161         if (aCode == EKeyBackspace)
       
 15162             {
       
 15163             iCaseMan->UpdateCase(EBackspaceEvent);
       
 15164             response = EKeyWasNotConsumed;
       
 15165             }
       
 15166         else
       
 15167             {
       
 15168             TInt newCursorPos = iUncommittedText.HigherPos(); //default, right or down
       
 15169             if (aCode == EKeyLeftArrow || aCode == EKeyUpArrow)
       
 15170                 {
       
 15171                 newCursorPos = iUncommittedText.LowerPos();
       
 15172                 }
       
 15173             iUncommittedText.SetSelection(newCursorPos, newCursorPos);
       
 15174             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 15175 
       
 15176             if (WesternPredictive())
       
 15177                 {
       
 15178                 if (CursorInsideWord())
       
 15179                     {
       
 15180                     if (aCode == EKeyLeftArrow || aCode == EKeyUpArrow)
       
 15181                         {
       
 15182                         MoveCursorToStartOfWordL();
       
 15183                         }
       
 15184                     else //right or down
       
 15185                         {
       
 15186                         MoveCursorToEndOfWordL();
       
 15187                         }
       
 15188                     }
       
 15189                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15190                 }
       
 15191             response = EKeyWasConsumed;
       
 15192             }
       
 15193         return ETrue;
       
 15194         }
       
 15195     return EFalse;
       
 15196     }
       
 15197 
       
 15198 TBool CAknFepManager::TryHandleCommonArrowAndBackspaceFunctionalityL(TInt aCode, 
       
 15199                                                                      TKeyResponse& aResponse)
       
 15200     {
       
 15201     TBool keyHandled = ETrue;
       
 15202     if ( !IsFepAwareTextEditor() )
       
 15203         {
       
 15204         aResponse=EKeyWasNotConsumed;
       
 15205         return keyHandled;
       
 15206         }
       
 15207 #ifdef RD_HINDI_PHONETIC_INPUT        
       
 15208 	if(iLanguageCapabilities.iInputLanguageCode == KLangHindiPhonetic)
       
 15209 		{
       
 15210 		if (aCode == EKeyBackspace)
       
 15211         	{
       
 15212         	CommitInlineEditL();
       
 15213         	FepUI()->HandleKeyL(aCode, EShortKeyPress);
       
 15214         	}
       
 15215 		if(IsFlagSet(CAknFepManager::EFlagNoMatches)) 
       
 15216 			{
       
 15217 			if(PreviousChar() == 0x003F && aCode != EKeyBackspace)
       
 15218 				{
       
 15219 				RemovePreviousCharacterL();		
       
 15220 				}
       
 15221 			ClearFlag(CAknFepManager::EFlagNoMatches);
       
 15222 			FepUI()->ExpireMultitapTimer();
       
 15223 			}
       
 15224 		iPtiEngine->HandleCommandL(EPtiCommandBreakSyllable, NULL );
       
 15225 		}
       
 15226 #endif		
       
 15227     if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
 15228         {
       
 15229         FepUI()->ExpireMultitapTimer();
       
 15230 
       
 15231         if (aCode == EKeyBackspace)
       
 15232             {
       
 15233             aResponse = EKeyWasNotConsumed; // let editor handle the move
       
 15234             }
       
 15235         else
       
 15236             {
       
 15237             aResponse = EKeyWasConsumed;
       
 15238             }
       
 15239         }
       
 15240     else
       
 15241         {
       
 15242         //selecting text
       
 15243         if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
 15244             {
       
 15245             if (iShiftKeypressMonitor->IsActive())
       
 15246                 {
       
 15247                 ResetShiftKeyMonitorL();    //don't want edit menu
       
 15248                 }
       
 15249             ClearFlag(EFlagQwertyShiftMode);
       
 15250             SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 15251             aResponse = EKeyWasNotConsumed;
       
 15252             return keyHandled;
       
 15253             }
       
 15254 
       
 15255         TCursorSelection currentEditorSelection;
       
 15256         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentEditorSelection);
       
 15257 
       
 15258         TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 15259 
       
 15260         // Translate key code to internal navi-event
       
 15261         switch( aCode )
       
 15262             {
       
 15263             case EKeyUpArrow:
       
 15264                 naviEvent = EUpNaviEvent;
       
 15265                 break;
       
 15266             case EKeyDownArrow:
       
 15267                 naviEvent = EDownNaviEvent;
       
 15268                 break;
       
 15269             case EKeyRightArrow:
       
 15270                 naviEvent = ERightNaviEvent;
       
 15271                 break;
       
 15272             case EKeyLeftArrow:
       
 15273                 naviEvent = ELeftNaviEvent;
       
 15274                 break;
       
 15275             default: // just leave it as NULL
       
 15276                 break;
       
 15277             }
       
 15278 
       
 15279         if (currentEditorSelection.Length())
       
 15280             {
       
 15281             // we have text selected - set cursor to start/end of current selection
       
 15282             TTmDocPosSpec newPos;
       
 15283             aResponse = NavigateFromSelectionL( currentEditorSelection, naviEvent, newPos );
       
 15284             if ( aCode != EKeyBackspace && WesternPredictive() )
       
 15285                 {
       
 15286                 if (CursorInsideWord())
       
 15287                     {
       
 15288                     TBool rightToleftParagraph = IsRightToLeftParagraph(newPos);
       
 15289                     if ( (rightToleftParagraph && naviEvent == ELeftNaviEvent) ||
       
 15290                          (!rightToleftParagraph && naviEvent == ERightNaviEvent) )
       
 15291                         {
       
 15292                         MoveCursorToEndOfWordL();
       
 15293                         }
       
 15294                     else
       
 15295                         {
       
 15296                         MoveCursorToStartOfWordL();
       
 15297                         }
       
 15298                     }
       
 15299 
       
 15300                 }
       
 15301             }
       
 15302         else if (!(EditorState()->Flags() & EAknEditorFlagNoLRNavigation))
       
 15303             {
       
 15304             if ((naviEvent != ENullNaviEvent) && HandleLoopingInNaviEventL(naviEvent))
       
 15305                 {
       
 15306                 aResponse=EKeyWasConsumed;
       
 15307                 }
       
 15308             else
       
 15309                 {
       
 15310                 if (iMode == ELatin)
       
 15311                     {
       
 15312                     // normal operation of Down/Up scroll keypress action.
       
 15313                     switch( aCode )
       
 15314                         {
       
 15315                         case EKeyUpArrow:
       
 15316                         case EKeyDownArrow:
       
 15317                             SimulateKeyEventL(EKeyF22);
       
 15318                             break;
       
 15319                         case EKeyRightArrow:
       
 15320                         case EKeyLeftArrow:
       
 15321                             {
       
 15322                             /*Hindi*/
       
 15323                             if( (TAknFepUiIndicInputManager :: IsIndicLangauge(
       
 15324                                       TLanguage(iLanguageCapabilities.iInputLanguageCode))) 
       
 15325                                  && IsZWSCharacterPresent() )
       
 15326                                 {
       
 15327                                 RemoveZWSCharacterL(EKeyLeftArrow); 
       
 15328                                 }
       
 15329                             }
       
 15330                             break;
       
 15331                         default: // nothing
       
 15332                             break;
       
 15333                         }
       
 15334                     }
       
 15335                 keyHandled = EFalse;
       
 15336                 }
       
 15337             }
       
 15338         }
       
 15339 
       
 15340     return keyHandled;
       
 15341     }
       
 15342 
       
 15343 /**
       
 15344 * Routine handled navigation and also backspace events at "beginning" of document
       
 15345 *
       
 15346 */
       
 15347 TBool CAknFepManager::HandleLoopingInNaviEventL(TWesternNaviEvent aNaviEvent)
       
 15348     {
       
 15349     TBool looping = EFalse;
       
 15350     TBool eventHandled = EFalse;
       
 15351     TTmDocPosSpec newCursorPos;
       
 15352 
       
 15353     // This routine may handle Left, Right and Backspace and nothing else
       
 15354     // Note that Up and Down cannot do any sort of document looping in FEP
       
 15355     if ( aNaviEvent != ELeftNaviEvent
       
 15356         && aNaviEvent != ERightNaviEvent
       
 15357         && aNaviEvent != EBackspaceEvent )
       
 15358         return eventHandled; // not consumed
       
 15359 
       
 15360     TTmDocPosSpec pos = DocPos();
       
 15361     TBool rightToLeftParagraph = IsRightToLeftParagraph(pos);
       
 15362 
       
 15363     TWesternNaviEvent incrementingNaviEvent = 
       
 15364                                           rightToLeftParagraph ? ELeftNaviEvent : ERightNaviEvent;
       
 15365     TWesternNaviEvent decrementingNaviEvent = 
       
 15366                                           rightToLeftParagraph ? ERightNaviEvent : ELeftNaviEvent;
       
 15367 
       
 15368     if (aNaviEvent == decrementingNaviEvent)
       
 15369         {
       
 15370         // Abandon early if we are not in the first line.
       
 15371         if ( InFirstLineAndFormatted( pos ) )
       
 15372             {
       
 15373             TTmDocPosSpec startPos;
       
 15374             GetVisualDocStart( startPos );
       
 15375              if( AtVisualStart( pos, startPos ) )
       
 15376                 {
       
 15377                 TTmDocPosSpec endPos;
       
 15378                 if ( !GetVisualDocEnd( endPos ) )
       
 15379                     {
       
 15380                     // End of document is not formatted. Value returned is just pos at DocLength.
       
 15381                     // So actually move the cursor there (this is guranteed to format the last line)
       
 15382                     // and the end End position is found a 2nd time.
       
 15383                     newCursorPos = endPos;
       
 15384                     SetCursorPositionL( newCursorPos );
       
 15385                     GetVisualDocEnd( endPos );
       
 15386                     }
       
 15387                 newCursorPos = endPos;
       
 15388                 looping = ETrue;
       
 15389                 }
       
 15390             }
       
 15391         }
       
 15392     else if (aNaviEvent == incrementingNaviEvent )
       
 15393         {
       
 15394         if ( InLastLineAndFormatted( pos ) )
       
 15395             {
       
 15396             TTmDocPosSpec endPos;
       
 15397             GetVisualDocEnd( endPos );
       
 15398             if( AtVisualEnd( pos, endPos, 
       
 15399                              iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() ) )
       
 15400                 {
       
 15401                 TTmDocPosSpec startPos;
       
 15402                 if ( !GetVisualDocStart( startPos ) )
       
 15403                     {
       
 15404                     // Document was not formatted at docPos(0).  So actually move the cursor
       
 15405                     // to that line at least, and then ask for the start pos again.
       
 15406                     newCursorPos = startPos;
       
 15407                     SetCursorPositionL( newCursorPos );
       
 15408                     GetVisualDocStart( startPos );
       
 15409                     }
       
 15410                 newCursorPos = startPos;
       
 15411                 looping = ETrue;
       
 15412                 }
       
 15413             }
       
 15414         }
       
 15415     else if ( aNaviEvent == EBackspaceEvent )
       
 15416         {
       
 15417         // Deletion is always logical, so the condition is simply to test the logical pos.
       
 15418         if ( pos.iPos ==0 )
       
 15419             {
       
 15420             eventHandled = ETrue;
       
 15421             }
       
 15422         }
       
 15423 
       
 15424     if (looping)
       
 15425         {
       
 15426         // This takes language issues into account, adjusting the cursor position:
       
 15427         AdjustPosSpecForInputLanguageAfterDocumentLoop( newCursorPos, aNaviEvent, 
       
 15428                                                         (aNaviEvent == incrementingNaviEvent) );
       
 15429         SetCursorPositionL( newCursorPos );
       
 15430         eventHandled = ETrue;
       
 15431         }
       
 15432     return eventHandled;
       
 15433     }
       
 15434 
       
 15435 void CAknFepManager::TransferFepStateToEditorL( TBool aFnLockSync )
       
 15436     {
       
 15437     // If editor in Fnlock state, need to set actual input mode
       
 15438     // because, in case of qwerty keypad alphanumeric editor there is no numeric mode
       
 15439     // numeric mode handle as FnLock
       
 15440 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15441 
       
 15442    if( aFnLockSync && iQwertyInputMode && iFnKeyManager && iFnKeyManager->FnKeyState()==CAknFepFnKeyManager::EFnKeyLock)
       
 15443         {
       
 15444         EditorState()->SetCurrentInputMode(EditorModeFromFepMode(ENumber));
       
 15445         // Indicator should not be reset, if menu is displaying from editor.
       
 15446         if(!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible))
       
 15447             iFnKeyManager->ClearFnKeyState(); 
       
 15448         }
       
 15449     else
       
 15450         {
       
 15451 #endif
       
 15452         EditorState()->SetCurrentInputMode(EditorModeFromFepMode(iMode));
       
 15453         
       
 15454 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 15455         }
       
 15456    if(iFnKeyManager && iFnKeyManager->FnKeyState()!=CAknFepFnKeyManager::EFnKeyLock)
       
 15457        iFnKeyManager->ClearFnKeyState();       
       
 15458 
       
 15459 #endif
       
 15460 
       
 15461     
       
 15462     if ((iMode == ELatin && iWesternPredictive &&
       
 15463         IsFlagSet(EFlagInsideInlineEditingTransaction)) 
       
 15464 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15465         ||(IsLanguageSupportPrediction() && IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15466 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15467 		)
       
 15468         {
       
 15469         EditorState()->SetInlineEditSpan(iUncommittedText);
       
 15470 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15471         if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 15472 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15473         TryRemoveNoMatchesIndicatorL();
       
 15474         UpdateCbaL(NULL);
       
 15475         }
       
 15476     else
       
 15477         {
       
 15478         EditorState()->SetInlineEditSpan(TCursorSelection(0,0));
       
 15479         }
       
 15480     EditorState()->SetCurrentCaseWithNoInitialisation(iCaseMan->CurrentCase());
       
 15481     if ( IsFlagSet( EFlagSupressAutoUpdate ) )
       
 15482         {
       
 15483         EditorState()->SetFlags( EditorState()->Flags() | EFlagSupressAutoUpdate );
       
 15484         }
       
 15485     else
       
 15486         {
       
 15487         EditorState()->SetFlags( EditorState()->Flags() & ~EFlagSupressAutoUpdate );
       
 15488         }
       
 15489     SetQwertyModeToInputcapbility();
       
 15490     }
       
 15491 
       
 15492 MAknFepManagerInterface* CAknFepManager::FepUI() const
       
 15493     {
       
 15494 #ifdef RD_SCALABLE_UI_V2
       
 15495     if ( iFepFullyConstructed && ( iFepPluginManager->PluginInputMode() != EPluginInputModeNone ) )
       
 15496         {
       
 15497         if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
 15498             {
       
 15499             return iFepPluginManager->CurrentFepInputUI() ?
       
 15500                 iFepPluginManager->CurrentFepInputUI() : iCurrentFepUI;
       
 15501             }
       
 15502         if ( iFepPluginManager->EnableITIOnFSQ() )
       
 15503             {
       
 15504             return iCurrentFepUI;
       
 15505             }
       
 15506         return iFepPluginManager->CurrentPluginInputFepUI();
       
 15507         }
       
 15508 #endif        
       
 15509     return iCurrentFepUI;
       
 15510     }
       
 15511 
       
 15512 void CAknFepManager::LaunchLanguagesPopupListL(TBool aLaunchedByTouchWin)
       
 15513     {
       
 15514 #ifdef RD_SCALABLE_UI_V2
       
 15515     if( iFepPluginManager->PluginInputMode() != EPluginInputModeNone &&
       
 15516         iFepPluginManager->PluginInputMode() != EPluginInputModeItut
       
 15517         // Add this condition for correction of dim features on FSQ
       
 15518         && iFepPluginManager->PluginInputMode() != EPluginInputModeFSQ )
       
 15519         {
       
 15520         iFepPluginManager->LaunchPenInputLanguageSelectionL(aLaunchedByTouchWin);
       
 15521         return;
       
 15522         }
       
 15523 #endif //RD_SCALABLE_UI_V2
       
 15524        
       
 15525     CArrayFixFlat<TInt>* languages = 
       
 15526         new( ELeave )CArrayFixFlat<TInt>( ELanguageArrayGranularity );
       
 15527     CleanupStack::PushL( languages );
       
 15528     iPtiEngine->GetAvailableLanguagesL( languages );
       
 15529 
       
 15530     // Create a list of languages for the dialog
       
 15531     CDesCArrayFlat* languagesList = 
       
 15532         new( ELeave )CDesCArrayFlat( ELanguageArrayGranularity );
       
 15533     CleanupStack::PushL( languagesList );
       
 15534 
       
 15535     // Item format should be "<icon_index>\t<item_text>"
       
 15536     _LIT( KIconIndexSelected,    "0\t" );
       
 15537     _LIT( KIconIndexNotSelected, "\t" );// No icon
       
 15538     
       
 15539     MPtiLanguage* lang = NULL;
       
 15540     TInt  currentLanguage = iSharedDataInterface->InputTextLanguage();
       
 15541     TInt selectedLanguageIndex = 0;
       
 15542     
       
 15543     for (TInt ii=0; ii < languages->Count(); ii++)
       
 15544         {
       
 15545         lang = iPtiEngine->GetLanguage( ( *languages )[ii] );
       
 15546         if (!lang)
       
 15547             {
       
 15548             User::Leave( KErrCorrupt );
       
 15549             }
       
 15550         // Buffer should contain both tabulator string and localized name:
       
 15551         HBufC* langStrBuf = HBufC::NewL( lang->LocalizedName().Length() + 3 );
       
 15552         CleanupStack::PushL( langStrBuf );
       
 15553         
       
 15554         TPtr langStrPtr = langStrBuf->Des();
       
 15555 
       
 15556         // If language is current language - use selected icon in lbx:
       
 15557         if( lang->LanguageCode() == currentLanguage )
       
 15558             {
       
 15559             langStrPtr.Append( KIconIndexSelected );
       
 15560             selectedLanguageIndex = ii;
       
 15561             }
       
 15562         else
       
 15563             {
       
 15564             langStrPtr.Append( KIconIndexNotSelected );    
       
 15565             }
       
 15566         langStrPtr.Append( lang->LocalizedName() );
       
 15567         languagesList->AppendL( langStrPtr );
       
 15568         CleanupStack::PopAndDestroy( langStrBuf );
       
 15569         }
       
 15570 
       
 15571     // Add icons to the listbox:
       
 15572     CArrayPtr<CGulIcon>* icons = new( ELeave ) CArrayPtrFlat<CGulIcon>(10);
       
 15573     CleanupStack::PushL( icons );
       
 15574     LoadIconL( icons, EMbmAvkonQgn_prop_sub_current, 
       
 15575                EMbmAvkonQgn_prop_sub_current_mask );
       
 15576 
       
 15577     TInt index = 0;
       
 15578     SetFlag( EFlagForegroundUIComponentVisible );
       
 15579     CleanupStack::Pop( icons );	// iUiInterface->LaunchListPopupL takes ownership immediately
       
 15580 #ifdef RD_SCALABLE_UI_V2 
       
 15581     /* tp teleca fix 17.9.2009 to IKIM-7VK8GG*/
       
 15582     /*if( iFepFullyConstructed && iFepPluginManager)
       
 15583             {
       
 15584             iFepPluginManager->SetMenuState();            
       
 15585             }*/
       
 15586     // tp teleca fix end
       
 15587 #endif              
       
 15588     // Fire up the dialog
       
 15589 #ifdef RD_SCALABLE_UI_V2
       
 15590     iCancelPopupInQwerty = aLaunchedByTouchWin;
       
 15591 #endif //RD_SCALABLE_UI_V2
       
 15592     TUid fepUid = CCoeEnv::Static()->FepUid();
       
 15593     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 15594     TInt returnValue = iUiInterface->LaunchListPopupL(R_AVKON_T9_LANGUAGES_QUERY, index, 
       
 15595                                                       selectedLanguageIndex, languagesList, icons);
       
 15596 #ifdef RD_SCALABLE_UI_V2
       
 15597     iCancelPopupInQwerty = EFalse;
       
 15598 #endif //RD_SCALABLE_UI_V2    
       
 15599     PrepareFepAfterDialogExitL(fepUid);
       
 15600     CleanupStack::PopAndDestroy( languagesList );
       
 15601 
       
 15602     if(returnValue == EAknSoftkeyOk)
       
 15603         {
       
 15604         // Selected item index from the languages array
       
 15605         HandleChangeInFocusL();
       
 15606 
       
 15607         // The user has changed language and the local language is not used any more.
       
 15608         iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
 15609         if (EditorState())
       
 15610             {
       
 15611             EditorState()->SetLocalLanguage( ELangTest );
       
 15612             }
       
 15613 
       
 15614         TBool westernPredictiveInUse = WesternPredictive();
       
 15615 
       
 15616 // Truncate autocompletion portion on change of writing language
       
 15617 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15618 		RemoveSuggestedAdvanceCompletionL();
       
 15619 #endif // RD_INTELLIGENT_TEXT_INPUT   
       
 15620         //Hindi Change Bug Fix
       
 15621         iSharedDataInterface->SetInputTextLanguage(languages->At(index));
       
 15622         CAknEnv::Static()->SettingCache().Update(KEikInputLanguageChange);
       
 15623         ChangeInputLanguageL(languages->At(index));           
       
 15624         SetFlag( EFlagNewSharedDataInputLanguage | EFlagNewSharedDataInputMode );
       
 15625 	  	// This pice of code TSW Fute error fixing.
       
 15626         // Display the confirmation msg if the dictionary is not available for
       
 15627         // Current language.
       
 15628 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 15629         // Display the confirmation msg only for Western languages
       
 15630         if (!IsChineseInputLanguage())
       
 15631         	{
       
 15632 	        if (!IsLanguageSupportPrediction())
       
 15633 	        	{
       
 15634 	        	LaunchConfirmationNoteL(R_AVKON_T9_NOTE_NO_AVAILABLE);
       
 15635 	        	}     
       
 15636         	}
       
 15637 #endif
       
 15638         
       
 15639           
       
 15640         }
       
 15641     CleanupStack::PopAndDestroy( languages );
       
 15642     }
       
 15643 
       
 15644 void CAknFepManager::LaunchRecognitionWithDictionaryPopupListL()
       
 15645     {
       
 15646 #ifdef RD_SCALABLE_UI_V2
       
 15647     if( iFepPluginManager && (iFepPluginManager->PluginInputMode() == EPluginInputModeHwr) )
       
 15648         {
       
 15649         iFepPluginManager->LaunchPenInputRecognitionWithDictionarySelectionL();
       
 15650         return;
       
 15651         }
       
 15652 #endif //RD_SCALABLE_UI_V2
       
 15653     }
       
 15654 
       
 15655 void CAknFepManager::LoadIconL( CArrayPtr<CGulIcon>* aIcons, 
       
 15656                                 TInt aBitmapId, 
       
 15657                                 TInt aMaskId )
       
 15658     {
       
 15659     CGulIcon* icon = CGulIcon::NewLC();
       
 15660     CFbsBitmap* bitmap = 0;
       
 15661     CFbsBitmap* mask = 0;
       
 15662     AknIconUtils::CreateIconL(  bitmap, mask, KAvkonBitmapFile, aBitmapId, aMaskId );
       
 15663     icon->SetBitmap( bitmap );
       
 15664     icon->SetMask( mask );
       
 15665     aIcons->AppendL( icon );
       
 15666     CleanupStack::Pop( icon );
       
 15667     }
       
 15668 
       
 15669 
       
 15670 TBool CAknFepManager::IsInputModeAvailable(TInt aMode) const
       
 15671     {
       
 15672     TBool isAvailable = ETrue;
       
 15673     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
 15674     switch (aMode)
       
 15675         {
       
 15676         case ELatin:
       
 15677             isAvailable = !( ( inputLanguage == ELangPrcChinese ) &&
       
 15678                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 15679             break;
       
 15680         case EPinyin:
       
 15681             isAvailable = ( inputLanguage == ELangPrcChinese );
       
 15682             break;
       
 15683         case EStroke:
       
 15684             isAvailable = ( inputLanguage == ELangPrcChinese || 
       
 15685                 inputLanguage == ELangHongKongChinese || 
       
 15686                 inputLanguage == ELangTaiwanChinese);
       
 15687             break;
       
 15688         case ECangJie:
       
 15689             {
       
 15690             isAvailable = ( ( inputLanguage == ELangHongKongChinese ) &&
       
 15691                           iQwertyInputMode );
       
 15692 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15693 #ifdef __HALF_QWERTY_KEYPAD            
       
 15694             isAvailable = isAvailable && (EPtiKeyboardHalfQwerty != KeyboardLayout()); 
       
 15695 #endif //__HALF_QWERTY_KEYPAD
       
 15696 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15697             }
       
 15698             
       
 15699             break;
       
 15700         case EZhuyin:
       
 15701             isAvailable = ( inputLanguage == ELangTaiwanChinese );
       
 15702             break;
       
 15703         case EPRCFind:
       
 15704             isAvailable = ( ( inputLanguage == ELangPrcChinese ) &&
       
 15705                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 15706             break;
       
 15707         case EZhuyinFind:
       
 15708             isAvailable = ( ( inputLanguage == ELangTaiwanChinese ) &&
       
 15709                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 15710             break;
       
 15711         case EStrokeFind:
       
 15712             isAvailable = ( ( inputLanguage == ELangHongKongChinese ) &&
       
 15713                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 15714             break;
       
 15715         case EHiraganaKanji:
       
 15716             isAvailable = (inputLanguage == ELangJapanese);
       
 15717             break;
       
 15718         case EKatakana:
       
 15719             isAvailable = (inputLanguage == ELangJapanese );
       
 15720             break;
       
 15721         case EHindi:
       
 15722             isAvailable = (inputLanguage == ELangHindi );
       
 15723             break;
       
 15724         case EHangul:
       
 15725             isAvailable = (inputLanguage == ELangKorean );
       
 15726             break;
       
 15727         case ENativeNumber:
       
 15728             isAvailable = (inputLanguage == ELangHindi 
       
 15729                 || inputLanguage == ELangArabic 
       
 15730                 || inputLanguage == ELangUrdu
       
 15731                 || inputLanguage == ELangFarsi/*
       
 15732                 || ( inputLanguage == ELangThai && iFepPluginManager && 
       
 15733                      iFepPluginManager->PluginInputMode() != EPluginInputModeItut &&
       
 15734                      iFepPluginManager->PluginInputMode() != EPluginInputModeNone)*/ );
       
 15735         default:
       
 15736             break;
       
 15737         }
       
 15738     return isAvailable;
       
 15739     }
       
 15740 
       
 15741 TInt CAknFepManager::NewInputModeAfterLanguageChange() const
       
 15742     {
       
 15743     TInt inputMode = 0;
       
 15744     switch (iLanguageCapabilities.iInputLanguageCode)
       
 15745         {
       
 15746         case ELangPrcChinese:
       
 15747             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 15748                 {
       
 15749                 inputMode = ELatin; // EPRCFind from hashkey loop
       
 15750                 }
       
 15751             else
       
 15752                 {
       
 15753                 inputMode = EPinyin;
       
 15754                 }
       
 15755             break;
       
 15756         case ELangHongKongChinese:
       
 15757             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 15758                 {
       
 15759                 inputMode = EStrokeFind;
       
 15760                 }
       
 15761             else
       
 15762                 {
       
 15763                 TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 15764 	            if (iQwertyInputMode && 
       
 15765 	            	sharedDataMode == ECangJie)
       
 15766 	            	{
       
 15767 	            	inputMode = ECangJie;
       
 15768 	            	}
       
 15769 	            else
       
 15770 	            	{
       
 15771 	            	inputMode = EStroke;
       
 15772 	            	}
       
 15773                 }
       
 15774             break;
       
 15775         case ELangTaiwanChinese:
       
 15776             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 15777                 {
       
 15778                 inputMode = EZhuyinFind;
       
 15779                 }
       
 15780             else
       
 15781                 {
       
 15782                 inputMode = EZhuyin;
       
 15783                 }
       
 15784             break;
       
 15785         case ELangJapanese:
       
 15786             inputMode = EHiraganaKanji;
       
 15787             break;
       
 15788         case ELangKorean:
       
 15789             inputMode = EHangul;
       
 15790             break;
       
 15791         default:
       
 15792             inputMode = ELatin;
       
 15793             break;
       
 15794         }
       
 15795     return inputMode;
       
 15796     }
       
 15797 
       
 15798 void CAknFepManager::SetInputLanguageCapabilities(const TInt aInputLanguage)
       
 15799     {
       
 15800     iLanguageCapabilities.iInputLanguageCode = aInputLanguage;
       
 15801 
       
 15802     if ( aInputLanguage == ELangArabic || aInputLanguage == ELangHebrew || 
       
 15803          aInputLanguage == ELangFarsi  || aInputLanguage == ELangUrdu )
       
 15804         {
       
 15805         iLanguageCapabilities.iSupportsCase = EFalse;
       
 15806         iLanguageCapabilities.iRightToLeftLanguage = ETrue;
       
 15807         SetCursorTypeForInputDirection(EFalse);
       
 15808         }
       
 15809     else
       
 15810         {
       
 15811         /*Hindi*/
       
 15812         if ( aInputLanguage == ELangThai 
       
 15813         || (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(aInputLanguage)))
       
 15814         ) 
       
 15815             {
       
 15816             iLanguageCapabilities.iSupportsCase = EFalse;
       
 15817             }
       
 15818         else
       
 15819             {
       
 15820             iLanguageCapabilities.iSupportsCase = ETrue;
       
 15821             }
       
 15822         iLanguageCapabilities.iRightToLeftLanguage = EFalse;
       
 15823         SetCursorTypeForInputDirection(ETrue);
       
 15824         }
       
 15825 
       
 15826     TLanguage uiLanguage = User::Language();
       
 15827     iLanguageCapabilities.iArabicIndicDigitsAllowed = 
       
 15828              ( aInputLanguage == ELangArabic || uiLanguage == ELangArabic);
       
 15829     iLanguageCapabilities.iEasternArabicIndicDigitsAllowed = ( 
       
 15830         ( aInputLanguage == ELangUrdu || uiLanguage == ELangUrdu ) ||
       
 15831         ( aInputLanguage == ELangFarsi|| uiLanguage == ELangFarsi ) );
       
 15832     /*Hindi*/
       
 15833     iLanguageCapabilities.iIndicDigitsAllowed =  
       
 15834              ( (TAknFepUiIndicInputManager :: IsIndicDigitsSupported(TLanguage(aInputLanguage))) );
       
 15835     UpdateLocalDigitMode();
       
 15836 
       
 15837     MAknFepManagerInterface* fepUI = iLangMan->GetFepUI(ELatin, iCharWidth, ETrue);
       
 15838     MPtiLanguage* ptiLanguage = iPtiEngine->GetLanguage(fepUI->SupportLanguage(ELatin));
       
 15839     if (ptiLanguage) // can be NULL in some uncommon situations, see TAVN-6SWB4Z
       
 15840         {
       
 15841         iLanguageCapabilities.iSupportsWesternPredictive = 
       
 15842                                            ptiLanguage->HasInputMode(EPtiEnginePredictive);
       
 15843         // tp teleca change Korean lang does not support predictive
       
 15844         // and we want to disable predictive even with local editors
       
 15845         if(/*IsKoreanInputLanguage()*/GetInputLanguageFromSharedDataInterface() == ELangKorean )
       
 15846             {
       
 15847             iLanguageCapabilities.iSupportsWesternPredictive = EFalse;
       
 15848             }
       
 15849         
       
 15850         
       
 15851         // tp teleca change end
       
 15852 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15853         // Predictive QWERTY (XT9) changes ---->
       
 15854         iLanguageCapabilities.iSupportsWesternQwertyPredictive = 
       
 15855                                            ptiLanguage->HasInputMode(EPtiEngineQwertyPredictive );
       
 15856         if ( GetInputLanguageFromSharedDataInterface() == ELangKorean )
       
 15857             {
       
 15858             iLanguageCapabilities.iSupportsWesternQwertyPredictive = EFalse;            
       
 15859             }
       
 15860         
       
 15861         // Predictive QWERTY (XT9) changes <----
       
 15862 #ifdef __HALF_QWERTY_KEYPAD
       
 15863 		iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive = ptiLanguage->HasInputMode(EPtiEngineHalfQwertyPredictive );
       
 15864 #endif         
       
 15865 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15866         }
       
 15867 
       
 15868     if (!iLanguageCapabilities.iSupportsWesternPredictive 
       
 15869 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15870         && !iLanguageCapabilities.iSupportsWesternQwertyPredictive 
       
 15871         // Predictive QWERTY changes
       
 15872 #ifdef __HALF_QWERTY_KEYPAD
       
 15873 		&& !iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive 
       
 15874 #endif //__HALF_QWERTY_KEYPAD        
       
 15875 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15876         ) // Predictive QWERTY changes
       
 15877         {
       
 15878         SetWesternPredictive(EFalse);
       
 15879         }
       
 15880     }
       
 15881 
       
 15882 TInt CAknFepManager::SubstituteSublanguageId(const TInt aUiLanguage) const
       
 15883     {
       
 15884     return DefaultInputLanguageFromUILanguage(aUiLanguage);
       
 15885     }
       
 15886 
       
 15887 TTmDocPosSpec CAknFepManager::DocPos()
       
 15888     {
       
 15889     TTmDocPosSpec docPos = TTmDocPosSpec();
       
 15890     TTmDocPos rawDocPos;
       
 15891     TBool gotPos = EFalse;
       
 15892     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 15893     if (docNavi)
       
 15894     	{
       
 15895         docNavi->GetDocPos(rawDocPos);
       
 15896         gotPos = ETrue;
       
 15897     	}
       
 15898     else
       
 15899     	{
       
 15900 	    CTextView* textView = TextView();
       
 15901 	    if (textView)
       
 15902 	        {
       
 15903 	        TextView()->GetCursorPos(rawDocPos);
       
 15904 	        gotPos = ETrue;
       
 15905 	        }
       
 15906     	}
       
 15907     if (gotPos)
       
 15908     	{
       
 15909         docPos.iPos = rawDocPos.iPos;
       
 15910         TTmDocPosSpec::TType docPosType = 
       
 15911                       rawDocPos.iLeadingEdge ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing;
       
 15912         docPos.iType = docPosType;
       
 15913         }
       
 15914     return docPos;
       
 15915     }
       
 15916 
       
 15917 /**
       
 15918 * This method needs EditorState() to exist
       
 15919 *
       
 15920 */
       
 15921 CTextView* CAknFepManager::TextView() const
       
 15922     {
       
 15923     if (EditorState())
       
 15924         {
       
 15925         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 15926         if (formAccessor)
       
 15927             {
       
 15928             return formAccessor->GetTextView();
       
 15929             }
       
 15930         }
       
 15931     return NULL;
       
 15932     }
       
 15933 
       
 15934 CTextLayout* CAknFepManager::TextLayout() const
       
 15935     {
       
 15936     if( EditorState() )
       
 15937         {
       
 15938         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 15939         if (formAccessor)
       
 15940             {
       
 15941             return formAccessor->GetTextLayout();
       
 15942             }
       
 15943         }
       
 15944     return NULL;
       
 15945     }
       
 15946     
       
 15947 CPlainText* CAknFepManager::PlainText() const
       
 15948     {
       
 15949     return iUiInterface->PlainText(EditorState());
       
 15950     }
       
 15951 
       
 15952 /**
       
 15953 * Checks if the paragraph containing aPos is Right to left.
       
 15954 * This routine will return nonsense if
       
 15955 *   - TextLayout() does not return a pointer
       
 15956 *   - the position passed is not in the formatted region
       
 15957 *
       
 15958 * Note, the return value from FindDocPos is thrown away
       
 15959 */
       
 15960 TBool CAknFepManager::IsRightToLeftParagraph(TTmDocPosSpec aPos) const
       
 15961     {
       
 15962     TTmPosInfo2 posInfo;
       
 15963     TTmLineInfo lineInfo;
       
 15964     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 15965     if (docNavi)
       
 15966     	{
       
 15967     	docNavi->FindDocPos(aPos, posInfo, lineInfo);
       
 15968     	}
       
 15969 	else
       
 15970 		{
       
 15971 	    CTextLayout* textLayout = TextLayout();
       
 15972 	    if (textLayout)
       
 15973 	        {
       
 15974 	        textLayout->TagmaTextLayout().FindDocPos(aPos, posInfo, lineInfo);
       
 15975 	        }
       
 15976 		}
       
 15977 		
       
 15978     return lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 15979     }
       
 15980 
       
 15981 
       
 15982 void CAknFepManager::FindAdjacentChunks(const TTmDocPosSpec& aPos,
       
 15983                                         CTmTextLayout::TTmChunkDescription& aLeft, 
       
 15984                                         CTmTextLayout::TTmChunkDescription& aRight) const
       
 15985     {
       
 15986     aLeft.iStart = -1;
       
 15987     aLeft.iEnd = -1;
       
 15988     aLeft.iRightToLeft = EFalse;
       
 15989     aRight.iStart = -1;
       
 15990     aRight.iEnd = -1;
       
 15991     aRight.iRightToLeft = EFalse;
       
 15992 
       
 15993     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 15994     if (docNavi)
       
 15995     	{
       
 15996     	docNavi->FindAdjacentChunks(aPos, aLeft, aRight);
       
 15997     	}
       
 15998     else
       
 15999     	{
       
 16000     CTextLayout* textLayout = TextLayout();
       
 16001     if (textLayout)
       
 16002         {
       
 16003         textLayout->TagmaTextLayout().FindAdjacentChunks(aPos, aLeft, aRight);
       
 16004         }
       
 16005     	}
       
 16006     }
       
 16007 
       
 16008 
       
 16009 TBool CAknFepManager::GetNextVisualRightCharacter( TInt& aPosition )
       
 16010     {
       
 16011     TTmDocPosSpec pos = DocPos();
       
 16012     TTmPosInfo2 info;
       
 16013     TBool nextPositionFound = EFalse;
       
 16014     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16015     if (docNavi)
       
 16016     	{
       
 16017     	nextPositionFound = docNavi->GetNextVisualCursorPos(pos, info, EFalse);
       
 16018     	}
       
 16019     else
       
 16020     	{
       
 16021 	    CTextLayout* textLayout = TextLayout();
       
 16022 	    if (textLayout)
       
 16023 	        {
       
 16024 	        nextPositionFound = textLayout->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 16025                                                                                    info, 
       
 16026                                                                                    EFalse);
       
 16027 	        }
       
 16028         }
       
 16029     if (nextPositionFound)
       
 16030         {
       
 16031         aPosition = info.iDocPos.iPos;
       
 16032 
       
 16033         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16034         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16035         FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16036 
       
 16037         if ( !rightChunk.iRightToLeft )
       
 16038             {
       
 16039             aPosition -= 1;
       
 16040             }
       
 16041         }
       
 16042     return nextPositionFound;
       
 16043     }
       
 16044 
       
 16045 TBool CAknFepManager::GetNextVisualLeftCharacter( TInt& aPosition )
       
 16046     {
       
 16047     TTmDocPosSpec pos = DocPos();
       
 16048     TTmPosInfo2 info;
       
 16049     TBool nextPositionFound = EFalse;
       
 16050     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16051     if (docNavi)
       
 16052     	{
       
 16053     	nextPositionFound = docNavi->GetNextVisualCursorPos(pos, info, ETrue);
       
 16054     	}
       
 16055     else
       
 16056     	{
       
 16057 	    CTextLayout* textLayout = TextLayout();
       
 16058 	    if (textLayout)
       
 16059 	        {
       
 16060 	        nextPositionFound = TextLayout()->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 16061                                                                                      info, 
       
 16062                                                                                      ETrue);
       
 16063 	        }
       
 16064         }
       
 16065     if (nextPositionFound)
       
 16066         {
       
 16067         aPosition = info.iDocPos.iPos;
       
 16068         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16069         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16070         FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16071 
       
 16072         if ( leftChunk.iRightToLeft )
       
 16073             {
       
 16074             aPosition -= 1;
       
 16075             }
       
 16076         if (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 16077             {
       
 16078             aPosition = pos.iPos -1;
       
 16079             }
       
 16080         }
       
 16081     return nextPositionFound;
       
 16082     }
       
 16083 
       
 16084 void CAknFepManager::FindVisualRightOfWord(TInt& aPosition)
       
 16085     {
       
 16086     TTmDocPosSpec pos = DocPos();
       
 16087     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16088     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16089     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16090 
       
 16091     if ( rightChunk.iRightToLeft )
       
 16092         {
       
 16093         FindStartOfWord(aPosition);
       
 16094         }
       
 16095     else
       
 16096         {
       
 16097         FindEndOfWord(aPosition);
       
 16098         }
       
 16099     }
       
 16100 
       
 16101 void CAknFepManager::FindVisualLeftOfWord(TInt& aPosition)
       
 16102     {
       
 16103     TTmDocPosSpec pos = DocPos();
       
 16104     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16105     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16106     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16107 
       
 16108     if ( leftChunk.iRightToLeft)
       
 16109         {
       
 16110         FindEndOfWord(aPosition);
       
 16111         }
       
 16112     else
       
 16113         {
       
 16114         FindStartOfWord(aPosition);
       
 16115         }
       
 16116     }
       
 16117 
       
 16118 
       
 16119 
       
 16120 TBool CAknFepManager::GetVisualDocStart( TTmDocPosSpec& aPos) const
       
 16121     {
       
 16122     // Set up the initial try as leading to the first logical character
       
 16123     // It is a requirement that this position is at least in the first line
       
 16124     TTmDocPosSpec pos(0, TTmDocPosSpec::ELeading);
       
 16125 
       
 16126     // Need to record if we are in aleft to right paragraph or not
       
 16127     TBool leftToRightParagraph = !IsRightToLeftParagraph(pos);
       
 16128 
       
 16129     TBool success(EFalse);
       
 16130     CTextLayout* textLayout = TextLayout();
       
 16131     TTmDocPosSpec docPos;
       
 16132     if (AknFepDocumentNavigation() || textLayout)
       
 16133         {
       
 16134 //      This was written because Tagma's LineExtreme() method did not seem to work
       
 16135         success = GetAknFepLineExtreme( pos, !leftToRightParagraph, docPos );
       
 16136         }
       
 16137 
       
 16138     if (success)
       
 16139         aPos = docPos;
       
 16140     else // Possible cleanup; action for when there is insufficient information
       
 16141         {
       
 16142         aPos.iPos = 0;
       
 16143         aPos.iType = TTmDocPosSpec::ELeading;
       
 16144         }
       
 16145 
       
 16146     return success;
       
 16147     }
       
 16148 
       
 16149 TBool CAknFepManager::GetVisualDocEnd( TTmDocPosSpec& aPos) const
       
 16150     {
       
 16151     TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 16152 
       
 16153     // Set up the initial try as trailing after the last logical character
       
 16154     // It is a requirement that this position is at least in the last line
       
 16155     TTmDocPosSpec pos(docLength, TTmDocPosSpec::ETrailing);
       
 16156 
       
 16157     // Need to record if we are in a left to right paragraph or not
       
 16158     TBool leftToRightParagraph = !IsRightToLeftParagraph(pos);
       
 16159 
       
 16160     TBool success(EFalse);
       
 16161     CTextLayout* textLayout = TextLayout();
       
 16162     TTmDocPosSpec docPos;
       
 16163     if (AknFepDocumentNavigation() || textLayout)
       
 16164         {
       
 16165         // This was written because Tagma's LineExtreme() method did not seem to work
       
 16166         success = GetAknFepLineExtreme( pos, leftToRightParagraph, docPos );
       
 16167         }
       
 16168 
       
 16169     if (success)
       
 16170         aPos = docPos;
       
 16171     else // Possible cleanup; action for when there is insufficient information
       
 16172         {
       
 16173         aPos.iPos = docLength;
       
 16174         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16175         }
       
 16176     return success;
       
 16177     }
       
 16178 
       
 16179 
       
 16180 TBool CAknFepManager::GetAknFepLineExtreme( const TTmDocPosSpec& aPos, TBool aToRight,
       
 16181         TTmDocPosSpec& aExtreme) const
       
 16182     {
       
 16183     TBool success(EFalse);
       
 16184 
       
 16185     TTmPosInfo2 posInfo;
       
 16186     TTmLineInfo lineInfo;
       
 16187     TBool found = EFalse;
       
 16188     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16189     if (docNavi)
       
 16190     	{
       
 16191     	found = docNavi->FindDocPos(aPos, posInfo, lineInfo);
       
 16192     	}
       
 16193     else
       
 16194     	{
       
 16195 	    CTextLayout* textLayout = TextLayout();
       
 16196 	    if ( textLayout )
       
 16197 	        {
       
 16198 	        found = textLayout->TagmaTextLayout().FindDocPos(aPos, posInfo, lineInfo);
       
 16199 	        }
       
 16200     	}
       
 16201 
       
 16202     if ( found )
       
 16203         {
       
 16204         // Make a selection of the line info.  Cursor first, Anchar 2nd:
       
 16205         TCursorSelection theWholeLine( lineInfo.iEnd-1, lineInfo.iStart );
       
 16206 
       
 16207         TWesternNaviEvent event;
       
 16208         if ( aToRight )
       
 16209             event = ERightNaviEvent;
       
 16210         else
       
 16211             event = ELeftNaviEvent;
       
 16212 
       
 16213         GetAvkonDefinedVisualLimitsOfSelection( theWholeLine, event, aExtreme, NULL );
       
 16214         success = ETrue;
       
 16215         }
       
 16216 
       
 16217     return success;
       
 16218     }
       
 16219 
       
 16220 
       
 16221 /**
       
 16222 * This routine analyses a selection (Does not have to be a real selection, but the datastructure
       
 16223 * is used as input) to find its visual start or end, according to the passed parameter
       
 16224 * The algo used is:
       
 16225 * - First find the top line of the selection.
       
 16226 * - Then find the bottom line of the selection.
       
 16227 * - Look at the two lines' directionality (from the paragraph they belong to) and decide what the overall
       
 16228 * directionality of the selection is.  Thus right/left can be translated to increment/decrement.
       
 16229 * (Note that Up is always decrement; down is always increment). So that allows the key actions to be
       
 16230 * correctly grouped, and allows it to be determined which keys act from the top or the bottom line
       
 16231 * (Decrement always acts from the top line; Increment always acts from the bottom line)
       
 16232 *
       
 16233 * - When the keys are handled, the action is again translated back to right/left according to the key-
       
 16234 * grouping and whether you are acting from the top line or from the bottom line.  Eg, decrement in RTL
       
 16235 * line is visually to the Right.
       
 16236 * - the appropriate "ExtremePos" API is called passing in the position on the line in which we are acting
       
 16237 *
       
 16238 */
       
 16239 void CAknFepManager::GetAvkonDefinedVisualLimitsOfSelection(
       
 16240     const TCursorSelection& aSelection,
       
 16241     TWesternNaviEvent aEvent,
       
 16242     TTmDocPosSpec& aLimitPos,
       
 16243     TWesternNaviEvent* aEffectiveRightOrLeftEvent ) const
       
 16244     {
       
 16245     // in case an irrelvant event is sent, initialize aLimitPos to something safe
       
 16246     aLimitPos.iPos = 0;
       
 16247     aLimitPos.iType = TTmDocPosSpec::ELeading;
       
 16248 
       
 16249     TTmDocPosSpec lowLogicalPos( aSelection.LowerPos(), TTmDocPosSpec::ELeading );
       
 16250     TTmDocPosSpec highLogicalPos( aSelection.HigherPos(), TTmDocPosSpec::ETrailing );
       
 16251 
       
 16252     // this records what the resulting Right/left direction (for optional return)
       
 16253     TWesternNaviEvent effectiveEvent = aEvent;
       
 16254 
       
 16255     // Get line and paragraph of the lower limit of the selection:
       
 16256     TTmPosInfo2 posInfo;
       
 16257     TTmLineInfo lineInfo;
       
 16258     TBool lowIsRightToLeft;
       
 16259     TBool highIsRightToLeft;
       
 16260     TBool layoutExists = EFalse;
       
 16261     
       
 16262     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16263     if (docNavi)
       
 16264     	{
       
 16265     	docNavi->FindDocPos(lowLogicalPos, posInfo, lineInfo);
       
 16266         lowIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16267     	docNavi->FindDocPos(highLogicalPos, posInfo, lineInfo);
       
 16268         highIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16269         layoutExists = ETrue;
       
 16270     	}
       
 16271     else
       
 16272     	{
       
 16273 	    CTextLayout* textLayout = TextLayout();
       
 16274 	    if (textLayout)
       
 16275 	        {
       
 16276 	        textLayout->TagmaTextLayout().FindDocPos(lowLogicalPos, posInfo, lineInfo);
       
 16277 	        lowIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16278 	        textLayout->TagmaTextLayout().FindDocPos(highLogicalPos, posInfo, lineInfo);
       
 16279 	        highIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16280 	        layoutExists = ETrue;
       
 16281 	        }
       
 16282     	}
       
 16283         
       
 16284     if (layoutExists)
       
 16285     	{
       
 16286         // Decide on the net directionality. This if looks a bit laboured, but it
       
 16287         // exhibits the Averell policy.
       
 16288         TBool netDirectionIsRightToLeft(EFalse);
       
 16289         if ( lowIsRightToLeft == highIsRightToLeft )
       
 16290             netDirectionIsRightToLeft = lowIsRightToLeft;
       
 16291         else
       
 16292             netDirectionIsRightToLeft = lowIsRightToLeft;// ambiguous - Take first paragraph
       
 16293 
       
 16294         if ( netDirectionIsRightToLeft )
       
 16295             switch ( aEvent )
       
 16296             {
       
 16297             case ELeftNaviEvent:
       
 16298             case EDownNaviEvent:
       
 16299                 effectiveEvent = ELeftNaviEvent;
       
 16300                 aLimitPos = LeftVisualExtremePos( highLogicalPos, lowLogicalPos.iPos, 
       
 16301                                                   highLogicalPos.iPos );
       
 16302                 break;
       
 16303             case ERightNaviEvent:
       
 16304             case EUpNaviEvent:
       
 16305                 effectiveEvent = ERightNaviEvent;
       
 16306                 aLimitPos = RightVisualExtremePos(lowLogicalPos, lowLogicalPos.iPos, 
       
 16307                                                   highLogicalPos.iPos );
       
 16308                 break;
       
 16309             default:
       
 16310             // No action. Only the events above are handled.
       
 16311                 break;
       
 16312             }
       
 16313         else
       
 16314             switch (aEvent)
       
 16315             {
       
 16316             case ELeftNaviEvent:
       
 16317             case EUpNaviEvent:
       
 16318                 effectiveEvent = ELeftNaviEvent;
       
 16319                 aLimitPos = LeftVisualExtremePos( lowLogicalPos, lowLogicalPos.iPos, 
       
 16320                                                   highLogicalPos.iPos);
       
 16321                 break;
       
 16322             case ERightNaviEvent:
       
 16323             case EDownNaviEvent:
       
 16324                 effectiveEvent = ERightNaviEvent;
       
 16325                 aLimitPos = RightVisualExtremePos( highLogicalPos, lowLogicalPos.iPos, 
       
 16326                                                    highLogicalPos.iPos );
       
 16327                 break;
       
 16328             default:
       
 16329             // No action. Only the events above are handled.
       
 16330                 break;
       
 16331             }
       
 16332         }
       
 16333 
       
 16334     else
       
 16335         {
       
 16336         // No text layout: Left or Up naviEvent gives low end; Right or down give high end
       
 16337         switch ( aEvent )
       
 16338             {
       
 16339             case ELeftNaviEvent:
       
 16340             case EUpNaviEvent:
       
 16341                 effectiveEvent = ELeftNaviEvent;
       
 16342                 aLimitPos = lowLogicalPos;
       
 16343                 break;
       
 16344             case ERightNaviEvent:
       
 16345             case EDownNaviEvent:
       
 16346                 effectiveEvent = ERightNaviEvent;
       
 16347                 aLimitPos = highLogicalPos;
       
 16348                 break;
       
 16349             default:
       
 16350             // No action. Only the events above are handled.
       
 16351                 break;
       
 16352             }
       
 16353         }
       
 16354     // return the effective direction (Right or Left)
       
 16355     if ( aEffectiveRightOrLeftEvent )
       
 16356         *aEffectiveRightOrLeftEvent = effectiveEvent;
       
 16357 
       
 16358     }
       
 16359 
       
 16360 
       
 16361 TTmDocPosSpec CAknFepManager::LeftVisualExtremePos( const TTmDocPosSpec& aStartPos, 
       
 16362                                                     TInt aMinPos, TInt aMaxPos ) const
       
 16363     {
       
 16364     // Start at start and find adjacent left chunks repeatedly until we find no more chunks, or our max or min
       
 16365     // is within a chunk
       
 16366     TTmDocPosSpec currentPos = aStartPos;
       
 16367     CTextLayout* textLayout = TextLayout();
       
 16368     if (AknFepDocumentNavigation() || textLayout)
       
 16369         {
       
 16370         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16371         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16372 
       
 16373         TInt iterations(0);
       
 16374         TBool endFound(EFalse);
       
 16375 
       
 16376         while( !endFound && iterations < KMaxChunkWalkIterations )
       
 16377             {
       
 16378             iterations++;
       
 16379             FindAdjacentChunks(currentPos, leftChunk, rightChunk);
       
 16380             // Try to move to left end of left chunk
       
 16381             endFound = LeftEndOfChunkWithinRange( leftChunk, aMinPos, aMaxPos, currentPos );
       
 16382             }
       
 16383         }
       
 16384     return currentPos;
       
 16385     }
       
 16386 
       
 16387 TTmDocPosSpec CAknFepManager::RightVisualExtremePos( const TTmDocPosSpec& aStartPos, 
       
 16388                                                      TInt aMinPos, TInt aMaxPos ) const
       
 16389     {
       
 16390     // Start at start and find adjacent right chunks repeatedly until we find no more chunks, or our max or min
       
 16391     // is within a chunk
       
 16392     TTmDocPosSpec currentPos = aStartPos;
       
 16393     CTextLayout* textLayout = TextLayout();
       
 16394     if (AknFepDocumentNavigation() || textLayout)
       
 16395         {
       
 16396         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16397         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16398 
       
 16399         TInt iterations(0);
       
 16400         TBool endFound(EFalse);
       
 16401 
       
 16402         while( !endFound && iterations < KMaxChunkWalkIterations )
       
 16403             {
       
 16404             iterations++;
       
 16405             FindAdjacentChunks(currentPos, leftChunk, rightChunk);
       
 16406             // Try to move to left end of left chunk
       
 16407             endFound = RightEndOfChunkWithinRange( rightChunk, aMinPos, aMaxPos, currentPos );
       
 16408             }
       
 16409         }
       
 16410     return currentPos;
       
 16411     }
       
 16412 
       
 16413 TBool CAknFepManager::LeftEndOfChunkWithinRange( const CTmTextLayout::TTmChunkDescription& aChunk,
       
 16414                                          TInt aMinPos, TInt aMaxPos, TTmDocPosSpec& aNewPos) const
       
 16415     {
       
 16416     TBool constrained = EFalse;
       
 16417     TInt leftEnd;
       
 16418     if ( !ChunkIsValid( aChunk ) )
       
 16419         {
       
 16420         constrained = ETrue; // leave the aNewPos as it is
       
 16421         }
       
 16422     else if ( aChunk.iStart >= iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() )
       
 16423         {
       
 16424         constrained = ETrue; // That chunk was a ficticious one:
       
 16425         }
       
 16426     else if ( aChunk.iEnd <= aMinPos || aChunk.iStart >= aMaxPos )
       
 16427         {
       
 16428         constrained = ETrue; // That chunk found does not actually overlap with valid range. Don't go there
       
 16429         }
       
 16430     else
       
 16431         {
       
 16432         if ( aChunk.iRightToLeft )
       
 16433             {
       
 16434             leftEnd =  aChunk.iEnd;
       
 16435             if ( leftEnd >= aMaxPos )
       
 16436                 {
       
 16437                 constrained = ETrue;
       
 16438                 aNewPos.iPos = aMaxPos;
       
 16439                 }
       
 16440             else
       
 16441                 {
       
 16442                 aNewPos.iPos = leftEnd;
       
 16443                 }
       
 16444             aNewPos.iType = TTmDocPosSpec::ETrailing;
       
 16445             }
       
 16446         else
       
 16447             {
       
 16448             leftEnd = aChunk.iStart;
       
 16449             if ( leftEnd <= aMinPos )
       
 16450                 {
       
 16451                 constrained = ETrue;
       
 16452                 aNewPos.iPos = aMinPos;
       
 16453                 }
       
 16454             else
       
 16455                 {
       
 16456                 aNewPos.iPos = leftEnd;
       
 16457                 }
       
 16458             aNewPos.iType = TTmDocPosSpec::ELeading;
       
 16459             }
       
 16460         }
       
 16461     return constrained;
       
 16462     }
       
 16463 
       
 16464 TBool CAknFepManager::RightEndOfChunkWithinRange( const CTmTextLayout::TTmChunkDescription& aChunk,
       
 16465                                          TInt aMinPos, TInt aMaxPos, TTmDocPosSpec& aNewPos) const
       
 16466     {
       
 16467     TBool constrained = EFalse;
       
 16468     TInt rightEnd;
       
 16469     if ( !ChunkIsValid( aChunk ) )
       
 16470         {
       
 16471         constrained = ETrue; // leave the aNewPos as it is
       
 16472         }
       
 16473     else if ( aChunk.iStart >= iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() )
       
 16474         {
       
 16475         constrained = ETrue; // That chunk was a ficticious one:
       
 16476         }
       
 16477     else if ( aChunk.iEnd <= aMinPos || aChunk.iStart >= aMaxPos )
       
 16478         {
       
 16479         constrained = ETrue; // That chunk found does not actually overlap with valid range. Don't go there
       
 16480         }
       
 16481     else
       
 16482         {
       
 16483         if ( aChunk.iRightToLeft )
       
 16484             {
       
 16485             rightEnd =  aChunk.iStart;
       
 16486             if ( rightEnd <= aMinPos )
       
 16487                 {
       
 16488                 constrained = ETrue;
       
 16489                 aNewPos.iPos = aMinPos;
       
 16490                 }
       
 16491             else
       
 16492                 {
       
 16493                 aNewPos.iPos = rightEnd;
       
 16494                 }
       
 16495             aNewPos.iType = TTmDocPosSpec::ELeading;
       
 16496             }
       
 16497         else
       
 16498             {
       
 16499             rightEnd = aChunk.iEnd;
       
 16500             if ( rightEnd >= aMaxPos )
       
 16501                 {
       
 16502                 constrained = ETrue;
       
 16503                 aNewPos.iPos = aMaxPos;
       
 16504                 }
       
 16505             else
       
 16506                 {
       
 16507                 aNewPos.iPos = rightEnd;
       
 16508                 }
       
 16509             aNewPos.iType = TTmDocPosSpec::ETrailing;
       
 16510             }
       
 16511         }
       
 16512     return constrained;
       
 16513     }
       
 16514 
       
 16515 /**
       
 16516 * This method handles the attachment to the chunk being navigated toward.
       
 16517 * Should only be used for Right and Left navigation.
       
 16518 * The actual direction of that chunk does not need to be looked at. Even if
       
 16519 * is the same direction as the one being moved from, you still attach to it, as it may not
       
 16520 * be logically contiguous.
       
 16521 */
       
 16522 void CAknFepManager::AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( TTmDocPosSpec& aPos, 
       
 16523                                                               TWesternNaviEvent aEvent ) const
       
 16524     {
       
 16525 
       
 16526     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16527     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16528     FindAdjacentChunks(aPos, leftChunk, rightChunk);
       
 16529 
       
 16530     TBool inputDirectionIsRTL = ( CurrentInputDirectionality() == TBidiText::ERightToLeft );
       
 16531 
       
 16532     switch (aEvent)
       
 16533         {
       
 16534         case ELeftNaviEvent:
       
 16535             {
       
 16536             // Do not attach to the left chunk if its directionality is not the same as aDirection
       
 16537             if ( ChunkIsValid( leftChunk ) )
       
 16538                 if ( COMPARE_BOOLS(inputDirectionIsRTL, leftChunk.iRightToLeft) )
       
 16539                     AttachToLeftChunk( aPos, leftChunk );
       
 16540             break;
       
 16541             }
       
 16542         case ERightNaviEvent:
       
 16543             {
       
 16544             if ( ChunkIsValid( rightChunk ) )
       
 16545                 if ( COMPARE_BOOLS(inputDirectionIsRTL, rightChunk.iRightToLeft) )
       
 16546                     AttachToRightChunk( aPos, rightChunk );
       
 16547             break;
       
 16548             }
       
 16549         default:
       
 16550             break;
       
 16551         }
       
 16552 
       
 16553     }
       
 16554 
       
 16555 
       
 16556 void CAknFepManager::AttachToRightChunk( TTmDocPosSpec& aPos, 
       
 16557                                          const CTmTextLayout::TTmChunkDescription& aRightChunk )
       
 16558     {
       
 16559     if ( aRightChunk.iRightToLeft )
       
 16560         {
       
 16561         aPos.iPos = aRightChunk.iEnd;
       
 16562         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16563         }
       
 16564     else
       
 16565         {
       
 16566         aPos.iPos = aRightChunk.iStart;
       
 16567         aPos.iType = TTmDocPosSpec::ELeading;
       
 16568         }
       
 16569     }
       
 16570 
       
 16571 void CAknFepManager::AttachToLeftChunk( TTmDocPosSpec& aPos, 
       
 16572                                         const CTmTextLayout::TTmChunkDescription& aLeftChunk )
       
 16573     {
       
 16574     if ( aLeftChunk.iRightToLeft )
       
 16575         {
       
 16576         aPos.iPos = aLeftChunk.iStart;
       
 16577         aPos.iType = TTmDocPosSpec::ELeading;
       
 16578         }
       
 16579     else
       
 16580         {
       
 16581         aPos.iPos = aLeftChunk.iEnd;
       
 16582         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16583         }
       
 16584     }
       
 16585 
       
 16586 /**
       
 16587 * This routine ensures that the cursor position is not attached to a chunk of opposite direction.
       
 16588 * For end of document, the normal routine can be used.
       
 16589 * For the start, usually do nothing, but there is the possibility of forcing position 0/Trailing, when
       
 16590 * the edge chunk and the input directionality are opposite.
       
 16591 */
       
 16592 void CAknFepManager::AdjustPosSpecForInputLanguageAfterDocumentLoop( TTmDocPosSpec& aPos, 
       
 16593                                      TWesternNaviEvent /*aNaviEvent*/, TBool aLoopToTop ) const
       
 16594     {
       
 16595 
       
 16596     // Looping based on a Left event should adjust the cursor position as if that point had
       
 16597     // been reached by navigation to that same visual position outwards from the body
       
 16598     // Define this as the effective navigation that has just happened:
       
 16599     TWesternNaviEvent effectiveEvent(ELeftNaviEvent);
       
 16600 
       
 16601     // Rule for this effective navigation is
       
 16602     // move to top of document : if paradirection is LTR then treat it as a LEFT navi
       
 16603     // move to top of document : if paradirection is RTL then treat it as RIGHT navi
       
 16604     // move to bottom of document : if paradirection is LTR then treat is as RIGHT navi
       
 16605     // move to bottom of document : if paradirection is RTL then treat as LEFT navi
       
 16606     // However, NOTE that decrementing events leads to looping to the END! (and vice versa)
       
 16607     TBool newParaIsRTL = IsRightToLeftParagraph(aPos);
       
 16608     if ( aLoopToTop && newParaIsRTL ) // move to top; RTL
       
 16609         effectiveEvent = ERightNaviEvent;
       
 16610     else if ( !aLoopToTop && !newParaIsRTL ) // move to bottom; LTR
       
 16611         effectiveEvent = ERightNaviEvent;
       
 16612 
       
 16613     if ( aLoopToTop )
       
 16614         {
       
 16615         //  There is no ficticious block of the paragraph direction at -1 to 0.  So we have to
       
 16616         // behave as if there is one:
       
 16617         //
       
 16618         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16619         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16620         CTmTextLayout::TTmChunkDescription& edgeChunk = leftChunk;
       
 16621 
       
 16622         FindAdjacentChunks(aPos, leftChunk, rightChunk);
       
 16623 
       
 16624         // Get input language direction
       
 16625         TBool inputDirectionIsRTL = ( CurrentInputDirectionality() == TBidiText::ERightToLeft );
       
 16626         if ( effectiveEvent == ELeftNaviEvent )
       
 16627             edgeChunk = leftChunk;
       
 16628         else
       
 16629             edgeChunk = rightChunk;
       
 16630 
       
 16631         // Check edgechunk for its direction
       
 16632         if ( !COMPARE_BOOLS( edgeChunk.iRightToLeft, inputDirectionIsRTL ) )
       
 16633             {
       
 16634             // Input language disagrees with the chunk that we are on,
       
 16635             aPos.iPos = 0;
       
 16636             aPos.iType = TTmDocPosSpec::ETrailing;
       
 16637             }
       
 16638 
       
 16639         }
       
 16640     else // Looping to the end of document
       
 16641         {
       
 16642         // There IS a ficticious block at the doc end, so use the usual routine.
       
 16643         AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( aPos, effectiveEvent );
       
 16644         }
       
 16645 
       
 16646     }
       
 16647 
       
 16648 TBool CAknFepManager::ChunkIsValid( const CTmTextLayout::TTmChunkDescription& aChunk )
       
 16649     {
       
 16650     TBool isValid(ETrue);
       
 16651 
       
 16652     const TInt KNotValid = -1;
       
 16653     if ( aChunk.iRightToLeft == KNotValid )
       
 16654         isValid = EFalse;
       
 16655     else if (aChunk.iStart == KNotValid )
       
 16656         isValid = EFalse;
       
 16657     else if (aChunk.iEnd == KNotValid )
       
 16658         isValid = EFalse;
       
 16659 
       
 16660 #ifdef _DEBUG
       
 16661     if (isValid)
       
 16662         __ASSERT_DEBUG( aChunk.iStart <= aChunk.iEnd, 
       
 16663                         AknFepPanic( EAknFepPanicBadCursorNavigationState ) );
       
 16664 #endif
       
 16665 
       
 16666     return isValid;
       
 16667     }
       
 16668 /**
       
 16669 * Finds the current input direction. This is determined as best as it can using
       
 16670 * - T9Interface as the preferred source of information
       
 16671 * - shared data (via AknTextUtils) if that fails
       
 16672 * - localLanguage overrides the above sources of information
       
 16673 * - when fep is in numeric mode it returns LTR
       
 16674 * - if FEP is in an irelevant mode, then LTR is returned
       
 16675 *
       
 16676 * @return TDirectionality::ELeftToRight for LTR alpha mode or numeric mode
       
 16677 */
       
 16678 TBidiText::TDirectionality CAknFepManager::CurrentInputDirectionality() const
       
 16679     {
       
 16680     TBidiText::TDirectionality directionality(TBidiText::ELeftToRight);
       
 16681 
       
 16682     // See if we are in a mode where the directionality is defined:
       
 16683     TBool checkForRTLValid(EFalse);
       
 16684 
       
 16685     switch (iMode )
       
 16686         {
       
 16687         case ELatin:
       
 16688         case ENumber:
       
 16689             checkForRTLValid = ETrue;
       
 16690             break;
       
 16691         default:
       
 16692             break;
       
 16693         }
       
 16694 
       
 16695     if ( checkForRTLValid )
       
 16696         {
       
 16697             MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage(); // No need to get language from PtiEngine ?
       
 16698             TInt inputLanguage = (ptilang)? ptilang->LanguageCode() : 0;
       
 16699             if ( inputLanguage )
       
 16700                 {
       
 16701                 directionality = TBidiText::ScriptDirectionality( (TLanguage)inputLanguage );
       
 16702                 checkForRTLValid = EFalse;
       
 16703                 }
       
 16704         }
       
 16705 
       
 16706     // if no T9 interface information is available, then go for other sources
       
 16707     // Note that you have to check for local language in this case (belt-and-braces)
       
 16708     if ( checkForRTLValid )
       
 16709         {
       
 16710         TLanguage localLanguage = ELangTest;
       
 16711         if ( GetLocalLanguage( localLanguage ) )
       
 16712             directionality = TBidiText::ScriptDirectionality( localLanguage );
       
 16713         else
       
 16714             directionality = AknTextUtils::CurrentScriptDirectionality();
       
 16715         }
       
 16716 
       
 16717     return directionality;
       
 16718     }
       
 16719 
       
 16720 
       
 16721 TBool CAknFepManager::GetLocalLanguage( TLanguage& aLanguage ) const
       
 16722     {
       
 16723     TBool result(EFalse);
       
 16724     // Check for a local language override
       
 16725     if ( IsFepAwareTextEditor() )
       
 16726         {
       
 16727         // For ITU-T keyboard we always use english in latin-only editors.               
       
 16728         // In case of qwerty keyboard, some languages can be used in latin
       
 16729         // only-editors, some require that english is used instead. That
       
 16730         // is decided here.
       
 16731         const TInt globalLang = iSharedDataInterface->InputTextLanguage();        
       
 16732         TBool allowTest = 
       
 16733 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 16734                            !iQwertyInputMode ||
       
 16735 #endif
       
 16736                            globalLang == ELangPrcChinese ||
       
 16737                            globalLang == ELangHongKongChinese ||
       
 16738                            globalLang == ELangTaiwanChinese ||
       
 16739                            globalLang == ELangThai ||
       
 16740                            globalLang == ELangGreek ||
       
 16741                            globalLang == ELangArabic ||
       
 16742                            globalLang == ELangFarsi ||                           
       
 16743                            globalLang == ELangUrdu ||
       
 16744                            globalLang == ELangHebrew ||
       
 16745                            globalLang == ELangRussian ||
       
 16746                            globalLang == ELangUkrainian ||
       
 16747                            globalLang == ELangHindi ||
       
 16748 #ifdef RD_MARATHI
       
 16749                            globalLang == ELangMarathi ||
       
 16750 #endif // RD_MARATHI
       
 16751 
       
 16752 #ifdef RD_HINDI_PHONETIC_INPUT  
       
 16753                            globalLang == KLangHindiPhonetic ||
       
 16754 #endif                           
       
 16755                            globalLang == ELangBulgarian || 
       
 16756                            globalLang == ELangVietnamese;
       
 16757                                           
       
 16758         if (allowTest && iAknEditorFlags & EAknEditorFlagLatinInputModesOnly &&
       
 16759             iLanguageCapabilities.iInputLanguageCode != ELangJapanese)
       
 16760             {
       
 16761             aLanguage = ELangEnglish;               
       
 16762             }
       
 16763         else
       
 16764             {
       
 16765             aLanguage = EditorState()->LocalLanguage();
       
 16766             }
       
 16767             
       
 16768         if ( aLanguage != ELangTest )
       
 16769             {   
       
 16770             MPtiLanguage* languageObject = NULL;
       
 16771             languageObject = iPtiEngine->GetLanguage(aLanguage);
       
 16772             if (languageObject)  // Check if the input language is supported.
       
 16773                 {                
       
 16774                 result = ETrue;
       
 16775                 }
       
 16776             else
       
 16777                 {
       
 16778                 aLanguage = ELangTest;
       
 16779                 }
       
 16780             }
       
 16781         }
       
 16782     return result;
       
 16783     }
       
 16784 
       
 16785 
       
 16786 TBool CAknFepManager::GetExposedDirectionOfText( TInt aPos, TBool aForward, 
       
 16787                                                  TBool& aIsRightToLeft ) const
       
 16788     {
       
 16789     TBool hasStrongCharacter(EFalse);
       
 16790 
       
 16791     // Access the plain text from the editor, getting a little bit at a time.
       
 16792 
       
 16793     TInt docLen = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 16794 
       
 16795     // Init with defaults for aForward = ETrue
       
 16796     TInt limit = docLen;
       
 16797     TInt increment = 1;
       
 16798     if ( !aForward )
       
 16799         {
       
 16800         limit = -1; // Loop does not execute if == limit
       
 16801         increment = -1;
       
 16802         }
       
 16803 
       
 16804     for ( TInt index = aPos; index != limit ; index += increment )
       
 16805         {
       
 16806         TChar ch = CharAt(index);
       
 16807         if ( iInlineTextDecorator->CharacterIsStrongRightToLeft( (TText)ch ) )
       
 16808             {
       
 16809             hasStrongCharacter = ETrue;
       
 16810             aIsRightToLeft = ETrue;
       
 16811             break;
       
 16812             }
       
 16813         else if ( iInlineTextDecorator->CharacterIsStrongLeftToRight( (TText)ch ) )
       
 16814             {
       
 16815             hasStrongCharacter = ETrue;
       
 16816             aIsRightToLeft = EFalse;
       
 16817             break;
       
 16818             }
       
 16819         }
       
 16820 
       
 16821     return hasStrongCharacter;
       
 16822     }
       
 16823 
       
 16824 TBool CAknFepManager::GetExposedDirectionOfTextInDescriptor( const TDesC& aText, TBool aForward, 
       
 16825                                                              TBool& aIsRightToLeft ) const
       
 16826     {
       
 16827     TBool hasStrongCharacter(EFalse);
       
 16828 
       
 16829     TInt textLen = aText.Length();
       
 16830 
       
 16831     TInt start = 0;
       
 16832     TInt limit = textLen;
       
 16833     TInt increment = 1;
       
 16834     if ( !aForward )
       
 16835         {
       
 16836         start = textLen-1;
       
 16837         limit = -1; // Loop does not execute if == limit
       
 16838         increment = -1;
       
 16839         }
       
 16840 
       
 16841     for ( TInt index = start; index != limit ; index += increment )
       
 16842         {
       
 16843         if ( iInlineTextDecorator->CharacterIsStrongRightToLeft( (TText)aText[index] ) )
       
 16844             {
       
 16845             hasStrongCharacter = ETrue;
       
 16846             aIsRightToLeft = ETrue;
       
 16847             break;
       
 16848             }
       
 16849         else if (  iInlineTextDecorator->CharacterIsStrongLeftToRight( (TText)aText[index] ) )
       
 16850             {
       
 16851             hasStrongCharacter = ETrue;
       
 16852             aIsRightToLeft = EFalse;
       
 16853             break;
       
 16854             }
       
 16855         }
       
 16856 
       
 16857     return hasStrongCharacter;
       
 16858     }
       
 16859 
       
 16860 TChar CAknFepManager::CharAt( TInt aPos ) const
       
 16861     {
       
 16862     TBuf<ESingleCharacter> chDes;
       
 16863 #ifdef RD_SCALABLE_UI_V2
       
 16864     if ( SemiFepAwareTextEditor( ETrue ) )
       
 16865 #else
       
 16866     if ( iInputCapabilities.FepAwareTextEditor() )
       
 16867 #endif // RD_SCALABLE_UI_V2    
       
 16868         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, aPos, 
       
 16869                                                                          ESingleCharacter);
       
 16870     if( chDes.Length() > 0 )
       
 16871         return chDes[0];
       
 16872     else
       
 16873         return TChar(0);
       
 16874     }
       
 16875 
       
 16876 
       
 16877 /**
       
 16878 * Navigate off of selected text using an Up/Down/Right/Left navigation event
       
 16879 *
       
 16880 * The code takes account of the paragraph directionality that the passed selection is
       
 16881 * found in.
       
 16882 *
       
 16883 * The new cursor position is resolved for ambuguity and set using SetCursorPosition and
       
 16884 * so it has the same side-effects:
       
 16885 *   iUncommittedText is set to the zero-width "cursor" state with the new cursor position
       
 16886 *   iUncommittedText is set into the FepAwareTextEditor state
       
 16887 *   iCaseManager is updated with a ENullNaviEvent
       
 16888 *   the doc pos is set in TextView object if present
       
 16889 */
       
 16890 TKeyResponse CAknFepManager::NavigateFromSelectionL(
       
 16891             const TCursorSelection& aSelection,
       
 16892             TWesternNaviEvent aNaviEvent,
       
 16893             TTmDocPosSpec& aPos)
       
 16894     {
       
 16895     if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut | ECcpuStateHashDown))
       
 16896         {
       
 16897         return EKeyWasNotConsumed;
       
 16898         }
       
 16899         
       
 16900     switch( aNaviEvent )
       
 16901         {
       
 16902         case EUpNaviEvent:
       
 16903         case EDownNaviEvent:
       
 16904         case ERightNaviEvent:
       
 16905         case ELeftNaviEvent:
       
 16906             // Carry on. Handle this event
       
 16907             break;
       
 16908         default: // just leave it as NULL
       
 16909             return EKeyWasNotConsumed;
       
 16910         }
       
 16911     // Find the visual end of the selection
       
 16912     TWesternNaviEvent effectiveEvent; // used to return either Right or Left event from next call:
       
 16913     GetAvkonDefinedVisualLimitsOfSelection( aSelection, aNaviEvent, aPos, &effectiveEvent );
       
 16914     AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( aPos, effectiveEvent );
       
 16915 
       
 16916     // Set this as the current position
       
 16917     SetCursorPositionL( aPos );
       
 16918 
       
 16919     return EKeyWasConsumed;
       
 16920     }
       
 16921 
       
 16922 
       
 16923 void CAknFepManager::SetCursorPositionL( const TTmDocPosSpec& aNewCursorPos, TBool aDragSelectOn )
       
 16924     {
       
 16925     if ( !iInputCapabilities.FepAwareTextEditor() )
       
 16926         return;
       
 16927 
       
 16928     TInt newAnchorPos = aNewCursorPos.iPos;
       
 16929 
       
 16930     if ( aDragSelectOn )
       
 16931         {
       
 16932         TCursorSelection selection;
       
 16933         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 16934         if ( selection.Length() > 0 ) // there is a selection. Keep the anchor
       
 16935             newAnchorPos = selection.iAnchorPos;
       
 16936         }
       
 16937 
       
 16938     iUncommittedText.SetSelection( aNewCursorPos.iPos, newAnchorPos );
       
 16939 
       
 16940     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 16941     iCaseMan->UpdateCase(ENullNaviEvent);
       
 16942 
       
 16943     // This is able to set the directional attachment of the cursor in a way that the FepAwareTextEditor interface cannot
       
 16944     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16945     if (docNavi)
       
 16946     	{
       
 16947     	docNavi->SetDocPosL(aNewCursorPos, aDragSelectOn);
       
 16948     	}
       
 16949     else
       
 16950     	{
       
 16951         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 16952         if (formAccessor)
       
 16953             {
       
 16954             CEikEdwin *edwin = static_cast<CEikEdwin *>( formAccessor->FormClientControl() );
       
 16955             if (edwin)
       
 16956                 edwin->SetCursorPosL( aNewCursorPos.iPos, aDragSelectOn );
       
 16957             }
       
 16958         }
       
 16959     }
       
 16960 
       
 16961 
       
 16962 
       
 16963 TBool CAknFepManager::InFirstLineAndFormatted( const TTmDocPosSpec& aPos ) const
       
 16964     {
       
 16965     return DocPosInFirstOrLastLineAndFormatted( aPos, ETrue);
       
 16966     }
       
 16967 
       
 16968 TBool CAknFepManager::InLastLineAndFormatted( const TTmDocPosSpec& aPos ) const
       
 16969     {
       
 16970     return DocPosInFirstOrLastLineAndFormatted( aPos, EFalse );
       
 16971     }
       
 16972 
       
 16973 TBool CAknFepManager::DocPosInFirstOrLastLineAndFormatted( const TTmDocPosSpec& aPos, 
       
 16974                                                            TBool aCheckFirstLine ) const
       
 16975     {
       
 16976     TBool success(EFalse);
       
 16977     TTmLineInfo lineInfo;
       
 16978     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16979     if (docNavi)
       
 16980     	{
       
 16981 	    success = docNavi->DocPosToLine( aPos, lineInfo);
       
 16982     	}
       
 16983     else
       
 16984     	{
       
 16985 	    CTextLayout* textLayout = TextLayout();
       
 16986 	    if ( textLayout )
       
 16987 	        {
       
 16988 	        success = textLayout->TagmaTextLayout().DocPosToLine( aPos, lineInfo);
       
 16989 	        }
       
 16990     	}
       
 16991     	
       
 16992         if ( success )
       
 16993             {
       
 16994             if ( aCheckFirstLine )
       
 16995                 success = (lineInfo.iLineNumber == 0 );
       
 16996             else
       
 16997                 {
       
 16998                 // Current position has yielded line information.  But how to tell if it is the last line?
       
 16999                 // Use the fact that the docpos of the last character will be in the last line.
       
 17000                 // Also account for the fact that these APIs report a character at docLength itself, a
       
 17001                 // ficticious end of paragraph character.  So use a >= docLength
       
 17002                 success = (lineInfo.iEnd >= 
       
 17003                            iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep()  );
       
 17004                 }
       
 17005             }
       
 17006         
       
 17007     return success;
       
 17008     }
       
 17009 
       
 17010 TBool CAknFepManager::AtVisualStart( const TTmDocPosSpec& aCurrentPos, 
       
 17011                                      const TTmDocPosSpec& aLimitPos ) const
       
 17012     {
       
 17013     TBool positionsAreTheSame(EFalse);
       
 17014     if ( aCurrentPos.iPos == aLimitPos.iPos && aCurrentPos.iType == aLimitPos.iType )
       
 17015         positionsAreTheSame = ETrue;
       
 17016     else if ( aCurrentPos.iPos == 0 && aCurrentPos.iType == TTmDocPosSpec::ETrailing )
       
 17017         positionsAreTheSame = ETrue;
       
 17018 
       
 17019     return positionsAreTheSame;
       
 17020     }
       
 17021 
       
 17022 TBool CAknFepManager::AtVisualEnd( const TTmDocPosSpec& aCurrentPos, 
       
 17023                                    const TTmDocPosSpec& aLimitPos, TInt aDocLength ) const
       
 17024     {
       
 17025     TBool positionsAreTheSame(EFalse);
       
 17026     if ( aCurrentPos.iPos == aLimitPos.iPos && aCurrentPos.iType == aLimitPos.iType )
       
 17027         positionsAreTheSame = ETrue;
       
 17028     else if ( aCurrentPos.iPos == aDocLength && aCurrentPos.iType == TTmDocPosSpec::ELeading )
       
 17029         positionsAreTheSame = ETrue;
       
 17030     else if ( aCurrentPos.iPos > aDocLength )
       
 17031         positionsAreTheSame = ETrue;
       
 17032 
       
 17033     return positionsAreTheSame;
       
 17034     }
       
 17035 
       
 17036 
       
 17037 void CAknFepManager::SetCursorType(TBool aIsLeftToRight)
       
 17038     {
       
 17039     if ( !BidiCursorRequired() )
       
 17040         return;
       
 17041 
       
 17042     // Optimization to prevent excessive Wserv communication:
       
 17043     if ( IsFlagSet( EFlagBidiCursorIsInitialized )
       
 17044         && COMPARE_BOOLS( !aIsLeftToRight, IsFlagSet( EFlagCursorPointsRightToLeft ) ) )
       
 17045         return;
       
 17046 
       
 17047     SetFlag( EFlagBidiCursorIsInitialized );
       
 17048 
       
 17049     MCoeFepAwareTextEditor* editor = iInputCapabilities.FepAwareTextEditor();
       
 17050     if (editor && editor->Extension1())
       
 17051         {
       
 17052         TCharFormat format;
       
 17053         TInt docPos = DocPos().iPos;
       
 17054         editor->GetFormatForFep(format, docPos);
       
 17055         
       
 17056         // Use Avkon routine to make all the layout decisions. It returns a TTextCursor object
       
 17057         TTextCursor newCursor;
       
 17058         AknCustomCursorSupport::GetBidiTextCursorFromFontSpec( format.iFontSpec, 
       
 17059                                                                !aIsLeftToRight, newCursor );
       
 17060         TBool setToTrue(ETrue);
       
 17061         editor->Extension1()->SetCursorType(setToTrue, newCursor);
       
 17062        
       
 17063         // Keep flag in step for optimization
       
 17064         if ( aIsLeftToRight )
       
 17065             ClearFlag( EFlagCursorPointsRightToLeft );
       
 17066         else
       
 17067             SetFlag( EFlagCursorPointsRightToLeft );
       
 17068         }
       
 17069     }
       
 17070 
       
 17071 TBool CAknFepManager::DeviceSupportsRTLLanguageL()
       
 17072     {
       
 17073     CArrayFixFlat<TInt>* languages = new (ELeave) CArrayFixFlat<TInt>(ELanguageArrayGranularity);
       
 17074     CleanupStack::PushL(languages);
       
 17075     iPtiEngine->GetAvailableLanguagesL(languages);
       
 17076 
       
 17077     TBool bidiCursorSuppressed(EFalse);
       
 17078 #if defined(__WINS__)
       
 17079     bidiCursorSuppressed = ETrue;
       
 17080     // Test (Disabled) mode (fake) UID, key and its value
       
 17081     const TInt KTestModeValue = 1; // 1 = show Bidi cursor
       
 17082 
       
 17083     CRepository* repository = NULL;
       
 17084     TRAPD(ret, repository = CRepository::NewL(KCRUidAknFep));
       
 17085     if (ret == KErrNone)
       
 17086         {
       
 17087         TInt modeValue = 0;
       
 17088         if (repository->Get(KAknFepTestModeKey, modeValue) == KErrNone)
       
 17089             {
       
 17090             if (modeValue == KTestModeValue)
       
 17091                 {
       
 17092                 bidiCursorSuppressed = EFalse; // show bidi cursor
       
 17093                 }
       
 17094             }
       
 17095         }
       
 17096     delete repository;
       
 17097 #endif
       
 17098 
       
 17099     TBool result = EFalse;
       
 17100     if (!bidiCursorSuppressed)
       
 17101         {
       
 17102         for (TInt jj = 0; jj < languages->Count(); jj++)
       
 17103             {
       
 17104             if (languages->At(jj) == ELangArabic ||
       
 17105                 languages->At(jj) == ELangHebrew ||
       
 17106                 languages->At(jj) == ELangFarsi  ||
       
 17107                 languages->At(jj) == ELangUrdu )
       
 17108                 // + others...
       
 17109                 {
       
 17110                 result = ETrue;
       
 17111                 break;
       
 17112                 }
       
 17113             }
       
 17114         }
       
 17115 
       
 17116     CleanupStack::PopAndDestroy();  // languages
       
 17117     return result;
       
 17118     }
       
 17119 
       
 17120 void CAknFepManager::CalculateEditorDigitType(TDigitType& aDestination)
       
 17121     {
       
 17122     TBool ASCIIDigits = EFalse;
       
 17123     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 17124 
       
 17125     if ( mop )
       
 17126         {
       
 17127         CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 17128         mop->MopGetObject( extendedInputCapabilities );
       
 17129 
       
 17130         if ( extendedInputCapabilities ) 
       
 17131             {
       
 17132             if ( extendedInputCapabilities->SupportsCapabilities(
       
 17133                 CAknExtendedInputCapabilities::ESupportsOnlyASCIIDigits ) )
       
 17134                 {
       
 17135                 // If this is true, then the inputcaps wants only ascii
       
 17136                 // digits -> you can, when the editor is seen as numeric,
       
 17137                 // be sure that only latin indicator is then wanted.
       
 17138                 ASCIIDigits = ETrue;
       
 17139                 }
       
 17140             }
       
 17141         }
       
 17142 
       
 17143     if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) 
       
 17144         {
       
 17145         // use of only latin characters implies that numbers are also western
       
 17146         ASCIIDigits = ETrue;
       
 17147         }
       
 17148 
       
 17149     AknTextUtils::TDigitModeQueryType editorType = AknTextUtils::EDigitModeEditorDefault;
       
 17150     TBool numberOnlyEditor = iPermittedInputModes == EAknEditorNumericInputMode;
       
 17151     if ( numberOnlyEditor )
       
 17152         {
       
 17153         editorType = AknTextUtils::EDigitModeNumberEditor;
       
 17154         if (ASCIIDigits)
       
 17155             {
       
 17156             editorType = AknTextUtils::EDigitModeLatinNumberEditor;
       
 17157             }
       
 17158         }
       
 17159         
       
 17160     if (iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
 17161         AknTextUtils::DigitModeQuery(editorType) && 
       
 17162         !ASCIIDigits)
       
 17163         {
       
 17164         aDestination = EDigitTypeArabicIndic;
       
 17165         }
       
 17166     else if (iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
 17167         AknTextUtils::DigitModeQuery(editorType)&& 
       
 17168         !ASCIIDigits)
       
 17169         {
       
 17170         aDestination = EDigitTypeEasternArabicIndic;
       
 17171         }    
       
 17172     /*Hindi*/    
       
 17173     else if ( iLanguageCapabilities.iIndicDigitsAllowed &&
       
 17174                     AknTextUtils::DigitModeQuery(editorType) && 
       
 17175         !ASCIIDigits)    
       
 17176         {
       
 17177         aDestination = EDigitTypeDevanagari;    
       
 17178         }
       
 17179     else
       
 17180         {
       
 17181         aDestination = EDigitTypeWestern;
       
 17182         }
       
 17183     }
       
 17184 
       
 17185 
       
 17186 void CAknFepManager::UpdateNumericEditorDigitType()
       
 17187     {
       
 17188     if (iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeUnknown)
       
 17189         {
       
 17190         CalculateEditorDigitType(iLanguageCapabilities.iNumericEditorDigitType);
       
 17191         }
       
 17192     }
       
 17193 
       
 17194 void CAknFepManager::UpdateLocalDigitMode()
       
 17195     {
       
 17196     TInt oldLocalDigitType = iLanguageCapabilities.iLocalDigitType;
       
 17197     CalculateEditorDigitType(iLanguageCapabilities.iLocalDigitType);
       
 17198     
       
 17199     if (oldLocalDigitType != iLanguageCapabilities.iLocalDigitType && 
       
 17200         iCaseMan) // happens in destructor   
       
 17201         {
       
 17202         UpdateIndicators(); 
       
 17203         }
       
 17204     }
       
 17205 
       
 17206 /**
       
 17207 * This routine should be called if the flag is set that says that the last navigation was to an
       
 17208 * ambiguous point.
       
 17209 * The routine checks to see if the event passed is
       
 17210 * - Right or Left Arrow
       
 17211 * - Would be the event to "jump" across the ambiguity. That is
       
 17212 *       - if at the "left" side of a LTR | RTL point, you need a Right arrow
       
 17213 *       - if at the "right" side of a LTR | RTL point, you need a Left arrow.
       
 17214 *       - if at the "left" side of a RTL | LTR point, you need a Right arrow
       
 17215 *       - if at the "right" side of a RTL | LTR point, you need a Left arrow.
       
 17216 *
       
 17217 */
       
 17218 // TKeyResponse CAknFepManager::AttemptCursorFlipAtAmbiguousPointL( const TKeyEvent& aKeyEvent, TEventCode aEventCode )
       
 17219 TKeyResponse CAknFepManager::AttemptCursorFlipAtAmbiguousPointL( const TUint aCode )
       
 17220     {
       
 17221     TKeyResponse response = EKeyWasNotConsumed;
       
 17222 
       
 17223     if ( IsFlagSet(EFlagAtDirectionallyAmbiguousPoint)  // only perform if already at ambi-point?
       
 17224         && !IsFlagSet(EFlagInsideInlineEditingTransaction) ) // do not flip if inside inline edit
       
 17225         {
       
 17226         if ( aCode == EKeyRightArrow || aCode == EKeyLeftArrow )
       
 17227             {
       
 17228             if ( iInputCapabilities.FepAwareTextEditor() && EditorState() 
       
 17229             && (AknFepDocumentNavigation() || TextView()) )
       
 17230                 {
       
 17231                 TTmDocPosSpec docPos = DocPos();
       
 17232                 TTextDirectionalInfo status = LocalTextDirectionalStatus( docPos );
       
 17233 
       
 17234                 CTmTextLayout::TTmChunkDescription leftChunk;
       
 17235                 CTmTextLayout::TTmChunkDescription rightChunk;
       
 17236                 FindAdjacentChunks(docPos, leftChunk, rightChunk);
       
 17237 
       
 17238                 if ( status.iBlockEnvironment == 
       
 17239                      TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock
       
 17240                     && aCode == EKeyRightArrow )
       
 17241                     {
       
 17242                     response = EKeyWasConsumed;
       
 17243                     // Set cursor to new directionality ( opposite to current )
       
 17244                     SetCursorTypeForTextDirection( status.iDirectionalStatus == 
       
 17245                                                    TTextDirectionalInfo::ERightToLeft );
       
 17246                     // Must actually change the docpos!
       
 17247                     AttachToRightChunk( docPos, rightChunk );
       
 17248                     SetCursorPositionL( docPos, ETrue ); // Drag any existing selection
       
 17249                     }
       
 17250                 else if (  status.iBlockEnvironment == 
       
 17251                            TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock
       
 17252                     && aCode == EKeyLeftArrow )
       
 17253                     {
       
 17254                     response = EKeyWasConsumed;
       
 17255                     // Effectively this toggles the direction of the cursor
       
 17256                     SetCursorTypeForTextDirection( status.iDirectionalStatus == 
       
 17257                                                    TTextDirectionalInfo::ERightToLeft );
       
 17258                     // Must actually change the docpos!
       
 17259                     AttachToLeftChunk( docPos, leftChunk );
       
 17260                     SetCursorPositionL( docPos, ETrue ); // Drag any existing selection
       
 17261                     }
       
 17262                 }
       
 17263             }
       
 17264         }
       
 17265     return response;
       
 17266     }
       
 17267 
       
 17268 
       
 17269 TInt CAknFepManager::PostEventCheckCallback(TAny* aObj)
       
 17270     {
       
 17271     TRAP_IGNORE(static_cast<CAknFepManager*>(aObj)->DoCursorDirectionCheckL());
       
 17272     return KErrNone;
       
 17273     }
       
 17274 
       
 17275 TBool CAknFepManager::BidiCursorRequired() const
       
 17276     {
       
 17277     return iDeviceSupportsRtlLanguage;
       
 17278     }
       
 17279 
       
 17280 void CAknFepManager::DoCursorDirectionCheckL()
       
 17281     {
       
 17282    iPostEventCheck->Cancel();
       
 17283     if(BidiCursorRequired()) 
       
 17284         {
       
 17285         AdjustCursorTypeForCurrentPosition();
       
 17286         }
       
 17287 
       
 17288     if ( !BidiCursorRequired() 
       
 17289     || (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode)) ))
       
 17290             {
       
 17291 		/*Hindi*/
       
 17292     	if( ( !WesternPredictive() ) && 
       
 17293 			( TAknFepUiIndicInputManager::IsIndicLangauge( 
       
 17294 					TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) ) && 
       
 17295 			( ( TAknFepUiIndicInputManager::IsCharVirama( 
       
 17296 					PreviousChar( ETrue ), TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) ) 
       
 17297 #ifdef RD_MARATHI
       
 17298 			|| ( IsEyeLashRaPresentL() && 
       
 17299 			TAknFepUiIndicInputManager::IsCharVirama(
       
 17300 					PreviousToPreviousChar( ETrue ), TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 17301 #endif
       
 17302 			)
       
 17303     		&& !( iInputCapabilities.SupportsSecretText() )
       
 17304     		)
       
 17305 			{
       
 17306 			TTmDocPosSpec pos = DocPos();
       
 17307 			pos.iType = TTmDocPosSpec::ETrailing;
       
 17308 		    TTmPosInfo2 info;
       
 17309 			TTmLineInfo lineInfo;
       
 17310 			TBool findAvailable = EFalse;
       
 17311 		    MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 17312 		    if (docNavi)
       
 17313 		    	{
       
 17314 			    docNavi->FindDocPos(pos, info, lineInfo);
       
 17315 			    findAvailable = ETrue;
       
 17316 		    	}
       
 17317 		    else
       
 17318 		    	{
       
 17319 				CTextLayout* textLayout = TextLayout();
       
 17320 	    		if ( textLayout )
       
 17321 	    			{
       
 17322 					textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);	    					    
       
 17323 					findAvailable = ETrue;
       
 17324 	    			}
       
 17325 		    	}
       
 17326 		    if (findAvailable)
       
 17327 		    	{
       
 17328 				TCursorSelection sel(info.iDocPos.iPos  ,info.iDocPos.iPos );
       
 17329 				iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 17330 		    	}
       
 17331 			}		
       
 17332 		}	
       
 17333     }
       
 17334 
       
 17335 void CAknFepManager::AdjustCursorTypeForCurrentPosition()
       
 17336     {
       
 17337     if ( iInputCapabilities.FepAwareTextEditor() && EditorState() 
       
 17338     && (AknFepDocumentNavigation() || TextView()) )
       
 17339         AdjustCursorTypeForPosition( DocPos() );
       
 17340     }
       
 17341 
       
 17342 void CAknFepManager::SchedulePostEventCheckL( TUint aCode )
       
 17343     {
       
 17344     
       
 17345     TBool isToPostEvent   = EFalse;    
       
 17346     TBool isIndicLanguage = TAknFepUiIndicInputManager :: 
       
 17347                             IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode));
       
 17348     
       
 17349     if ( BidiCursorRequired() )
       
 17350         {
       
 17351         switch ( aCode )
       
 17352             {
       
 17353             // Navigation cases:
       
 17354             case EKeyDownArrow:
       
 17355             case EKeyUpArrow:            
       
 17356             case EPtiKey1:
       
 17357             case EPtiKey2:
       
 17358             case EPtiKey3:
       
 17359             case EPtiKey4:
       
 17360             case EPtiKey5:
       
 17361             case EPtiKey6:
       
 17362             case EPtiKey7:
       
 17363             case EPtiKey8:
       
 17364             case EPtiKey9:
       
 17365             case EPtiKey0:
       
 17366                  {
       
 17367                     isToPostEvent = ETrue;
       
 17368                  }
       
 17369                  break;
       
 17370             case EKeyBackspace:
       
 17371             case EKeyDelete:
       
 17372                 {
       
 17373                     if(!isIndicLanguage)
       
 17374                     {
       
 17375                         isToPostEvent = ETrue;
       
 17376                     }
       
 17377                 }
       
 17378                 break;
       
 17379             case EKeyLeftArrow:
       
 17380             case EKeyRightArrow:
       
 17381                 {
       
 17382                     if(!isIndicLanguage)
       
 17383                     {
       
 17384                         isToPostEvent = ETrue;
       
 17385                     }
       
 17386                 }
       
 17387                 break;                
       
 17388             default:
       
 17389                 break;
       
 17390             }
       
 17391 
       
 17392         // If Repha has been inserted then do not post event.
       
 17393         if( isIndicLanguage )
       
 17394             {
       
 17395             if( aCode == EPtiKey1 && ( !iQwertyInputMode ) )
       
 17396                 {
       
 17397                 if( IsRephaPresent() 
       
 17398 #ifdef RD_MARATHI
       
 17399                 || IsEyeLashRaPresentL()
       
 17400 #endif
       
 17401                 )
       
 17402                     {
       
 17403                     isToPostEvent = EFalse;
       
 17404                     }
       
 17405                 }
       
 17406             }
       
 17407         }
       
 17408               
       
 17409         if(isIndicLanguage) // iQwertyInputMode check is added so as to ensure that the event is not posted for Qwerty mode. 
       
 17410         {
       
 17411             if((aCode == EKeyBackspace || aCode == EKeyDelete) && (!iQwertyInputMode))
       
 17412             {
       
 17413                 isToPostEvent = ETrue;
       
 17414             }           
       
 17415         } 
       
 17416         
       
 17417         if(isToPostEvent)
       
 17418         {
       
 17419             if ( iPostEventCheck->IsActive() )
       
 17420                 iPostEventCheck->Cancel();
       
 17421             iPostEventCheck->Start( TCallBack(PostEventCheckCallback, this) );
       
 17422         }                   
       
 17423     }
       
 17424 
       
 17425 void CAknFepManager::AdjustCursorTypeForPosition( const TTmDocPosSpec& aDocPos )
       
 17426     {
       
 17427 
       
 17428     TTextDirectionalInfo dirInfo = LocalTextDirectionalStatus( aDocPos );
       
 17429     // default clearing of this flag
       
 17430     ClearFlag( EFlagAtDirectionallyAmbiguousPoint );
       
 17431 
       
 17432     switch ( dirInfo.iBlockEnvironment )
       
 17433         {
       
 17434         case TTextDirectionalInfo::EUndefined:
       
 17435             // Set according to input direction
       
 17436             SetCursorTypeForTextDirection( CurrentInputDirectionality() == 
       
 17437                                            TBidiText::ELeftToRight );
       
 17438             break; // do nothing
       
 17439 
       
 17440         // All unambiguous cases
       
 17441         case TTextDirectionalInfo::EInsideBlock:
       
 17442         case TTextDirectionalInfo::EAtRightEndOfLine:
       
 17443         case TTextDirectionalInfo::EAtLeftEndOfLine:
       
 17444         case TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock:
       
 17445         case TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock:
       
 17446             SetCursorTypeForTextDirection( dirInfo.iDirectionalStatus == 
       
 17447                                            TTextDirectionalInfo::ELeftToRight );
       
 17448             break;
       
 17449 
       
 17450         // Ambiguous. Navigation has resulted in an ambiguous visual position. Set cursor according
       
 17451         // to current direction
       
 17452         case TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock:
       
 17453         case TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock:
       
 17454             SetCursorTypeForTextDirection( dirInfo.iDirectionalStatus == 
       
 17455                                            TTextDirectionalInfo::ELeftToRight );
       
 17456             SetFlag( EFlagAtDirectionallyAmbiguousPoint );
       
 17457             break;
       
 17458         default:
       
 17459             // Do nothing
       
 17460             break;
       
 17461         }
       
 17462     }
       
 17463 
       
 17464 void CAknFepManager::SetCursorTypeForTextDirection( TBool aLeftToRight )
       
 17465     {
       
 17466     SetCursorType( aLeftToRight );
       
 17467     }
       
 17468 
       
 17469 void CAknFepManager::SetCursorTypeForInputDirection( TBool /*aLeftToRight*/ )
       
 17470     {
       
 17471     // Do nothing
       
 17472     }
       
 17473 
       
 17474 CAknFepManager::TTextDirectionalInfo CAknFepManager::
       
 17475                                LocalTextDirectionalStatus( const TTmDocPosSpec& aDocPos ) const
       
 17476     {
       
 17477     TTextDirectionalInfo directionalInfo;
       
 17478 
       
 17479     MCoeFepAwareTextEditor* fepAwareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 17480     if ( !fepAwareTextEditor )
       
 17481         return directionalInfo;
       
 17482 
       
 17483     if ( aDocPos.iPos < 0 ) // somehow, we are before the first character
       
 17484         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17485     else if ( aDocPos.iPos > fepAwareTextEditor->DocumentLengthForFep() ) // (iPos = docLen still is within document)
       
 17486         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17487     else if ( fepAwareTextEditor->DocumentLengthForFep() == 0 ) // zero length; no document
       
 17488         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17489 
       
 17490     if ( directionalInfo.iDirectionalStatus == TTextDirectionalInfo::EUnknown )
       
 17491         {
       
 17492         CTmTextLayout::TTmChunkDescription leftChunk;
       
 17493         CTmTextLayout::TTmChunkDescription rightChunk;
       
 17494         FindAdjacentChunks(aDocPos, leftChunk, rightChunk);
       
 17495 
       
 17496     // Cases:
       
 17497     // position is within a chunk (chunks are continuous in logical index and same directionality.
       
 17498     //  ->Return directionality
       
 17499     // position is betweeen two chunks of opposite directionality
       
 17500     //  -> return simple ambiguity
       
 17501     // position is between two chnks of same directionality, but logical index is not contiguous
       
 17502     //  -> return complex ambiguity ; return directionality
       
 17503 
       
 17504         if ( leftChunk.iStart == -1 && rightChunk.iStart == -1 ) // 2 chunks invalid; direction stays EUnkonwn
       
 17505             {
       
 17506             directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENoDirectionalChunks;
       
 17507             }
       
 17508         else if ( leftChunk.iStart == -1 )  // no left block
       
 17509             {
       
 17510             directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EAtLeftEndOfLine;
       
 17511             directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17512             }
       
 17513         else if ( rightChunk.iStart == -1 ) // no right block
       
 17514             {
       
 17515             directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EAtRightEndOfLine;
       
 17516             directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17517             }
       
 17518         // Both chunks are the same direction.
       
 17519         // We are either nicely inside a block or the two blocks are at +/- 2, 4, etc levels
       
 17520         else if ( COMPARE_BOOLS( leftChunk.iRightToLeft, rightChunk.iRightToLeft ) )
       
 17521             {
       
 17522             // Can set direction from either chunk; use left one
       
 17523             directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17524 
       
 17525             if (leftChunk.iRightToLeft )
       
 17526                 {
       
 17527                 if ( leftChunk.iStart == rightChunk.iEnd ) // chunks are continguous
       
 17528                     directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EInsideBlock;
       
 17529                 else // Chunks are separated by 2, 4 etc. levels
       
 17530                     directionalInfo.iBlockEnvironment = ( aDocPos.iPos == leftChunk.iStart ) ?
       
 17531                         TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock :
       
 17532                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock;
       
 17533                 }
       
 17534             else
       
 17535                 {
       
 17536                 if ( leftChunk.iEnd == rightChunk.iStart ) // chunks are continguous
       
 17537                     directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EInsideBlock;
       
 17538                 else // Chunks are separated by 2, 4 etc. levels
       
 17539                     directionalInfo.iBlockEnvironment = ( aDocPos.iPos == leftChunk.iEnd ) ?
       
 17540                         TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock :
       
 17541                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock;
       
 17542                 }
       
 17543             }
       
 17544         else // Blocks are in opposite direction. Have to deal with all the values of the iType enum
       
 17545             {
       
 17546             TInt charPos;
       
 17547             switch( aDocPos.iType )
       
 17548                 {
       
 17549                 case TTmDocPosSpec::ETrailing: // position follows a block End
       
 17550                     {
       
 17551                     charPos = aDocPos.iPos - 1; //  attachment is to character[iPos-1] - now find it
       
 17552                     if ( leftChunk.iStart <= charPos && charPos < leftChunk.iEnd ) // pos is in left chunk
       
 17553                         {
       
 17554                         directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17555                         directionalInfo.iBlockEnvironment = 
       
 17556                             TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock;
       
 17557                         }
       
 17558                     else if( rightChunk.iStart <= charPos && charPos < rightChunk.iEnd ) // pos is in right chunk
       
 17559                         {
       
 17560                         directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17561                         directionalInfo.iBlockEnvironment = 
       
 17562                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17563                         }
       
 17564                     else // Probably impossible situation.  Supply reasonable defaults rather than panicking
       
 17565                         {
       
 17566                         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17567                         directionalInfo.iBlockEnvironment = 
       
 17568                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17569                         }
       
 17570                     break;
       
 17571                     }
       
 17572                 case TTmDocPosSpec::ELeading: // position precedes a block start
       
 17573                     {
       
 17574                     charPos = aDocPos.iPos; //  attachment is to character[iPos] - now find it
       
 17575                     if ( leftChunk.iStart <= charPos && charPos < leftChunk.iEnd ) // pos is in left chunk
       
 17576                         {
       
 17577                         directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17578                         directionalInfo.iBlockEnvironment = 
       
 17579                             TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock;
       
 17580                         }
       
 17581                     else if( rightChunk.iStart <= charPos && charPos < rightChunk.iEnd ) // pos is in right chunk
       
 17582                         {
       
 17583                         directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17584                         directionalInfo.iBlockEnvironment = 
       
 17585                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17586                         }
       
 17587                     else // Probably impossible situation.  Supply reasonable defaults rather than panicking
       
 17588                         {
       
 17589                         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17590                         directionalInfo.iBlockEnvironment = 
       
 17591                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17592                         }
       
 17593                     break;
       
 17594                     }
       
 17595                 case TTmDocPosSpec::ELeftToRight: // Is attached to a Left to right block
       
 17596                     {
       
 17597                     directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17598                     // If left chunk is RTL, then we are NOT attached to that left block
       
 17599                     // (ie. we are at left end of the right block)
       
 17600                     directionalInfo.iBlockEnvironment = leftChunk.iRightToLeft ?
       
 17601                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock : // must be in right chunk then (left end of it)
       
 17602                         TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock; // else in left chunk (right end of it)
       
 17603                     break;
       
 17604                     }
       
 17605                 case TTmDocPosSpec::ERightToLeft:
       
 17606                     {
       
 17607                     directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ERightToLeft;
       
 17608                     // If left chunk if RTL, then we are attached to that left block (ie. at right end of it)
       
 17609                     directionalInfo.iBlockEnvironment = leftChunk.iRightToLeft ? // is it in left chunk?
       
 17610                         TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock : // right end of left chunk
       
 17611                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17612                     break;
       
 17613                     }
       
 17614                 }
       
 17615 
       
 17616             }
       
 17617         }
       
 17618     return directionalInfo;
       
 17619     }
       
 17620 
       
 17621 
       
 17622 /**
       
 17623 * Redecoration is carried out if a neutral is exposed by the deletion to a directionality
       
 17624 * different to that which is was already marked.
       
 17625 *
       
 17626 * The routine leaves iUncommittedText again set to the (possibly new) cursor position.
       
 17627 *
       
 17628 */
       
 17629 void CAknFepManager::RedecorateAfterDeletionL( const TDesC& aTextThatWasDeleted  )
       
 17630     {
       
 17631     if (!EditorSupportsNeutralProtection())
       
 17632         return;
       
 17633 
       
 17634     if ( aTextThatWasDeleted.Length() == 0 )
       
 17635         return;
       
 17636 
       
 17637     TBool protect = ETrue;
       
 17638 
       
 17639     // Set up iUncommittedText with the current cursor position so that PreviousChar will work:
       
 17640     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 17641 
       
 17642     TTmDocPosSpec docPos = DocPos();
       
 17643     TInt docLen = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 17644 
       
 17645     TInt previousPos = docPos.iPos;
       
 17646     // Trailing iType actually points to character at index iPos - 1
       
 17647     if( docPos.iType == TTmDocPosSpec::ETrailing )
       
 17648         previousPos = previousPos -= 1;
       
 17649     TInt nextPos = previousPos + 1;
       
 17650 
       
 17651     // Perform no neutral protection if the beginning of the text is deleted.
       
 17652     // Note that there MAY be protection occuring if the delete is from the end so there is
       
 17653     // no corresponding test on DocLength. That is handled later where the paragraph direction
       
 17654     // is used for the "forward" directionality.
       
 17655     if ( previousPos < 0 )
       
 17656         return;
       
 17657 
       
 17658     // Up to 2 protection characters, one RTL and one LTR
       
 17659     TBuf<2> textToInsert;
       
 17660 
       
 17661     TBool adjacentPrecedingIsNeutral(EFalse);
       
 17662     TBool adjacentTrailingIsNeutral(EFalse);
       
 17663 
       
 17664     // See if either preceding or next is neutral
       
 17665     adjacentPrecedingIsNeutral = iInlineTextDecorator->CharacterIsNeutral( CharAt(previousPos) );
       
 17666     if ( nextPos < docLen )
       
 17667         adjacentTrailingIsNeutral = iInlineTextDecorator->CharacterIsNeutral( CharAt(nextPos) );
       
 17668 
       
 17669     if ( !adjacentPrecedingIsNeutral && !adjacentTrailingIsNeutral )
       
 17670         protect = EFalse;
       
 17671 
       
 17672     // Inits actually correspond to LTR, but they are only used if the bools indicating
       
 17673     // strong directionality found get set
       
 17674     TBool directionPrecedingDeleteIsRTL(EFalse);
       
 17675     TBool directionTrailingDeleteIsRTL(EFalse);
       
 17676     if ( protect )
       
 17677         {
       
 17678         TBool strongPreceding = GetExposedDirectionOfText( previousPos, EFalse, 
       
 17679                                                            directionPrecedingDeleteIsRTL );
       
 17680         TBool strongTrailing = GetExposedDirectionOfText( nextPos, ETrue, 
       
 17681                                                           directionTrailingDeleteIsRTL );
       
 17682         if (!strongTrailing)
       
 17683             {
       
 17684             TBool isRTLPara = IsRightToLeftParagraph(docPos);
       
 17685             directionTrailingDeleteIsRTL = isRTLPara;
       
 17686             strongTrailing = ETrue;
       
 17687             }
       
 17688         if ( !strongPreceding || !strongTrailing) // Must have strong in both directions
       
 17689             protect = EFalse;
       
 17690         else if ( COMPARE_BOOLS( directionPrecedingDeleteIsRTL, directionTrailingDeleteIsRTL ) ) // Must differ
       
 17691             protect = EFalse;
       
 17692         }
       
 17693 
       
 17694     TBool forwardProtection(EFalse);
       
 17695 
       
 17696     if ( protect )
       
 17697         {
       
 17698         protect = EFalse;
       
 17699         TBool deletedWasRTL;
       
 17700 
       
 17701         // Check for and do reverse protection
       
 17702         if ( adjacentPrecedingIsNeutral )
       
 17703             {
       
 17704             TBool deletedTextIsStrong = GetExposedDirectionOfTextInDescriptor( aTextThatWasDeleted, 
       
 17705                                                                                ETrue, 
       
 17706                                                                                deletedWasRTL ); // search forward into deleted stuff
       
 17707             if ( deletedTextIsStrong && (directionPrecedingDeleteIsRTL == deletedWasRTL))
       
 17708                 {
       
 17709                 protect = ETrue;
       
 17710                 forwardProtection = EFalse;
       
 17711                 if ( deletedWasRTL )
       
 17712                     textToInsert.Append( CAknFepInlineTextDecorator::ERightToLeftMark );
       
 17713                 else
       
 17714                     textToInsert.Append( CAknFepInlineTextDecorator::ELeftToRightMark );
       
 17715                 }
       
 17716             }
       
 17717 
       
 17718         // Check for and do forward protection
       
 17719         // Note it is possible to have both forward and reverse redecoration.
       
 17720         if ( adjacentTrailingIsNeutral )
       
 17721             {
       
 17722             TBool deletedTextIsStrong = GetExposedDirectionOfTextInDescriptor( aTextThatWasDeleted, 
       
 17723                                                                                EFalse, 
       
 17724                                                                                deletedWasRTL ); // search backward in deleted stuff
       
 17725             if (deletedTextIsStrong && (directionTrailingDeleteIsRTL == deletedWasRTL) )
       
 17726                 {
       
 17727                 protect = ETrue;
       
 17728                 forwardProtection = ETrue;
       
 17729                 if ( deletedWasRTL )
       
 17730                     textToInsert.Append( CAknFepInlineTextDecorator::ERightToLeftMark );
       
 17731                 else
       
 17732                     textToInsert.Append( CAknFepInlineTextDecorator::ELeftToRightMark );
       
 17733                 }
       
 17734             }
       
 17735         }
       
 17736 
       
 17737 
       
 17738     if ( protect )
       
 17739         {
       
 17740         StartInlineEditL(textToInsert);
       
 17741         CommitInlineEditWithoutResolutionL(*(iInputCapabilities.FepAwareTextEditor()), ETrue);
       
 17742         // iUncommittedText is now set to correct value by the Commitxxxx method
       
 17743         // Document position is adjusted to as to keep the cursor stable.
       
 17744         // Make a docPos. If reverse protection, then the position should trail
       
 17745         TTmDocPosSpec docPos( iUncommittedText.LowerPos() , TTmDocPosSpec::ETrailing );
       
 17746         // But if there has been forward Protection, then we have to back up the cursor by 1
       
 17747         // and lead. (This is OK too, if there is simultaneous reversse and forward protection)
       
 17748         if ( forwardProtection )
       
 17749             {
       
 17750             docPos.iPos = Max(docPos.iPos - 1, 0 );
       
 17751             docPos.iType = TTmDocPosSpec::ELeading;
       
 17752             }
       
 17753         SetCursorPositionL( docPos );
       
 17754         }
       
 17755     }
       
 17756 
       
 17757 TBool CAknFepManager::EditorSupportsNeutralProtection()
       
 17758     {
       
 17759     TBool ret = ETrue;
       
 17760     if ( !IsFepAwareTextEditor() )
       
 17761         ret = EFalse;
       
 17762 
       
 17763     else if (iInputCapabilities.SupportsSecretText())
       
 17764         ret = EFalse;
       
 17765 
       
 17766     else if ( iAknEditorFlags & EAknEditorFlagLatinInputModesOnly )
       
 17767         ret = EFalse;
       
 17768 
       
 17769     else if (iPermittedInputModes == EAknEditorNumericInputMode)
       
 17770         ret = EFalse;
       
 17771 
       
 17772     else if ( !CharIsValidInEditor( CAknFepInlineTextDecorator::ERightToLeftMark ) )
       
 17773         ret = EFalse;
       
 17774 
       
 17775     return ret;
       
 17776     }
       
 17777 
       
 17778 void CAknFepManager::CommitInlineEditWithoutResolutionL(MCoeFepAwareTextEditor& aFepAwareTextEditor, 
       
 17779                                                         TBool aCursorVisibility , TBool aClearPti )
       
 17780     {
       
 17781     aFepAwareTextEditor.SetInlineEditingCursorVisibilityL(aCursorVisibility);
       
 17782     /*
       
 17783     On any call to CommitFepInlineEditL, the mode will change
       
 17784     even when a leave event occurs.
       
 17785     */
       
 17786     ClearFlag(EFlagInsideInlineEditingTransaction | EFlagInsideMultitapInlineEditingTransaction);
       
 17787     ClearCcpuFlag(ECcpuStateNewPredictiveWord);
       
 17788     
       
 17789     if(aClearPti)
       
 17790         {
       
 17791         iPtiEngine->CommitCurrentWord();
       
 17792         }
       
 17793     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 17794     aFepAwareTextEditor.CommitFepInlineEditL(*coeEnv);
       
 17795     aFepAwareTextEditor.GetCursorSelectionForFep(iUncommittedText);
       
 17796     // iMatchState=EWordMatchFirst;
       
 17797     iCaseMan->UpdateCase(ENullNaviEvent);
       
 17798     }
       
 17799 
       
 17800 void CAknFepManager::WordConcatenationTimerTimeoutL()
       
 17801     {
       
 17802     iConcatenationTimer->Cancel();
       
 17803 
       
 17804     // add concatenated word to the UDB (a concatenated word is a compound word)
       
 17805     AddCompoundWordToUdbL();
       
 17806 
       
 17807 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 17808 	MoveCursorToEndOfWordL();
       
 17809 #endif
       
 17810     }
       
 17811 
       
 17812 
       
 17813 TKeyResponse CAknFepManager::HandlePredictiveNaviEventOutsideInlineEditL(TUint aCode, 
       
 17814                                                                          TKeyPressLength aLength)
       
 17815     {
       
 17816     TKeyResponse response = EKeyWasNotConsumed;
       
 17817 
       
 17818     TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 17819     if (aCode == EKeyLeftArrow)
       
 17820         {
       
 17821         naviEvent = ELeftNaviEvent;
       
 17822         }
       
 17823     else if (aCode == EKeyRightArrow)
       
 17824         {
       
 17825         naviEvent = ERightNaviEvent;
       
 17826         }
       
 17827     else if (aCode == EKeyBackspace)
       
 17828         {
       
 17829         naviEvent = EBackspaceEvent;
       
 17830         }
       
 17831 
       
 17832     TInt nextCharPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 17833     TBool nextPositionFound = EFalse;
       
 17834     if ( naviEvent == ERightNaviEvent )
       
 17835         {
       
 17836         nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 17837         }
       
 17838     else if ( naviEvent == ELeftNaviEvent )
       
 17839         {
       
 17840         nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 17841         }
       
 17842     else if ( naviEvent == EBackspaceEvent )
       
 17843         {
       
 17844         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 17845             {
       
 17846             TChar character = PreviousChar();
       
 17847             TChar::TBdCategory bdCategory = character.GetBdCategory();
       
 17848             // In case last character in buffer is number or Latin characters, needs to delete 
       
 17849             // character from left.
       
 17850             if (TChar::EEuropeanNumber == bdCategory || TChar::EArabicNumber == bdCategory ||
       
 17851                 TChar::ELeftToRight == bdCategory )
       
 17852                 {
       
 17853                 nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 17854                 }
       
 17855             else
       
 17856                 {
       
 17857                 nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 17858                 }
       
 17859             }
       
 17860         else
       
 17861             {
       
 17862             nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 17863             }
       
 17864         }
       
 17865 
       
 17866     if ( !nextPositionFound )
       
 17867         {
       
 17868         response = EKeyWasNotConsumed;
       
 17869         }
       
 17870     else // not looping - lets see what to do
       
 17871         {
       
 17872         TBuf<ESingleCharacter> characterBuffer;
       
 17873         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 17874                                                                         nextCharPos, 
       
 17875                                                                         ESingleCharacter);
       
 17876 
       
 17877         if ( !IsValidInLineCharacter( STATIC_CAST(TChar, characterBuffer[0])) )
       
 17878             {
       
 17879             // if the character is a non-alpha character; let it go
       
 17880             response=EKeyWasNotConsumed;
       
 17881             if (IsFlagSet(EFlagCompoundWord))
       
 17882                 {
       
 17883                 if  (STATIC_CAST(TChar, characterBuffer[0]).IsSpace())
       
 17884                     // we are navigating over a space so add any current compond word to the udb
       
 17885                     AddCompoundWordToUdbL();
       
 17886                 ClearFlag(EFlagCompoundWord);
       
 17887                 }
       
 17888         //allow to popup editsubmenu        
       
 17889         ClearCcpuFlag(ECcpuStateIgnoreStarUp);
       
 17890             }
       
 17891         else
       
 17892             {
       
 17893             if (FepUI()->HandleKeyL(aCode, aLength))
       
 17894                 {
       
 17895                 response=EKeyWasConsumed;
       
 17896                 }
       
 17897             }
       
 17898         }
       
 17899     return response;
       
 17900     }
       
 17901 
       
 17902 /**
       
 17903  * Call back function:
       
 17904  */
       
 17905 TInt CAknFepManager::DoSimulateKey(TAny* aThisPtr)
       
 17906     {
       
 17907     CAknFepManager* myobj = static_cast<CAknFepManager*>(aThisPtr);
       
 17908     TRAPD(error, myobj->HandleOwnedSimulateKeyL());
       
 17909     return error;
       
 17910     }
       
 17911 
       
 17912 void CAknFepManager::HandleOwnedSimulateKeyL()
       
 17913     {
       
 17914 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 17915 #ifdef __HALF_QWERTY_KEYPAD
       
 17916         if( KeyboardLayout() == EPtiKeyboardHalfQwerty )
       
 17917             {            
       
 17918             CCoeEnv::Static()->SimulateKeyEventL( iHalfQwertyLastKeyEvent, EEventKey );
       
 17919             }        
       
 17920         else
       
 17921 #endif //__HALF_QWERTY_KEYPAD        
       
 17922 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 17923     if (iSimulateKey > 0)
       
 17924         {
       
 17925         HandleKeyEventL(iSimulateKey, EShortKeyPress);
       
 17926         iSimulateKey = 0;
       
 17927         }
       
 17928     }
       
 17929 
       
 17930 /**
       
 17931  * This method is that the label of CBA is updated by aTextResId.
       
 17932  * @param aPosition   CBA position, either ELeftSoftkeyIndex or ERightSoftkeyIndex
       
 17933  * @param aCommandId  command id for softkey
       
 17934  * @param aTextResId  resource id to set string on label.
       
 17935  * @return TBool The return value is ETrue in case it is necessary to update CBA.
       
 17936  */
       
 17937 TBool CAknFepManager::UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId)
       
 17938     {
       
 17939     return iUiInterface->UpdateSoftkeyLabelL(aPosition, aCommandId, aTextResId);
       
 17940     }
       
 17941 
       
 17942 void CAknFepManager::DoLaunchSctAndPctL(TInt aResourceId, TShowSctMode aShowSctMode)
       
 17943     {
       
 17944     TBool replace = EFalse;
       
 17945     TBool disableRecentItemRow = EFalse;
       
 17946     
       
 17947     if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT)
       
 17948         {
       
 17949         // The editor doesn't allow SCT.
       
 17950         return;
       
 17951         }
       
 17952     if ( EditorType() == CAknExtendedInputCapabilities::EEikSecretEditorBased )
       
 17953         {
       
 17954         
       
 17955         disableRecentItemRow = ETrue;
       
 17956         }    
       
 17957     
       
 17958     if (IsCcpuFlagSet(ECcpuStateCbaSymbol) && 
       
 17959         iMode == ELatin && WesternPredictive(ELatin) && 
       
 17960         iPtiEngine->LastEnteredKey() == EPtiKey1)
       
 17961         {
       
 17962         // User is entering special character as result of pressing key '1' and
       
 17963         // cycling through candidates until left softkey turns into "Symbol". In
       
 17964         // that case we want to replace last cahracter instead of adding new one.
       
 17965         replace = ETrue;
       
 17966         }
       
 17967     
       
 17968     //Commit characters in latin multitap as some editors may call CancelFepTransaction()
       
 17969     //which will be received before the focus change notification.
       
 17970     if (IsFeatureSupportedJapanese())
       
 17971         {
       
 17972         TryCloseUiL();
       
 17973         }
       
 17974     else
       
 17975         {
       
 17976 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 17977         if(!(WesternPredictive()))
       
 17978 #endif
       
 17979         CommitInlineEditL();
       
 17980         }
       
 17981 
       
 17982     if (!EditorHasFreeSpace())
       
 17983         {
       
 17984         return;
       
 17985         }
       
 17986     
       
 17987     // get the SCT resource id from editor default settings
       
 17988     TInt currentEditorSCTResId = GetCurrentEditorSCTResId();
       
 17989     TInt charMap = aResourceId;
       
 17990     if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 17991         {        
       
 17992         if (charMap == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 17993             {
       
 17994             charMap = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 17995             }
       
 17996         }
       
 17997     if (!charMap)
       
 17998         {
       
 17999         // override numeric keymap if necessary. flag is for non standard charmaps
       
 18000         TInt standardNumericCharMap = EDefaultNumericCharMapResId;
       
 18001         if ((iMode == ENumber || iMode == ENativeNumber) &&
       
 18002             !(iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) &&
       
 18003             (iCharWidth == EHalfWidthChar) &&
       
 18004             ( (iAknEditorNumericKeymap != EAknEditorAlphanumericNumberModeKeymap) ||
       
 18005               (iPermittedInputModes == EAknEditorNumericInputMode) ))
       
 18006             {
       
 18007             standardNumericCharMap = NumericModeSCTResourceId();
       
 18008             }
       
 18009         charMap = standardNumericCharMap;
       
 18010         }
       
 18011         
       
 18012     if ( charMap == ENoCharacters && !IsAbleToLaunchSCT())
       
 18013         {
       
 18014     	currentEditorSCTResId = charMap;
       
 18015         }
       
 18016 
       
 18017     if (currentEditorSCTResId)
       
 18018         {
       
 18019         TBuf<32> specialChars;
       
 18020 
       
 18021         TInt sctChars = EAknSCTChiChineseInputModes;
       
 18022         TInt afterSctChars = EAknSCTHalfCase;
       
 18023 
       
 18024         if (iCharWidth == EFullWidthChar)
       
 18025             {
       
 18026             sctChars = EAknSCTFullCase;
       
 18027             if (iMode == ELatin)
       
 18028                 {
       
 18029                 afterSctChars = EAknSCTUpperCase;
       
 18030                 if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
 18031                     {
       
 18032                     afterSctChars = EAknSCTLowerCase;
       
 18033                     }
       
 18034                 }
       
 18035             else if (iMode == ENumber||iMode == ENativeNumber)
       
 18036                 {
       
 18037                 afterSctChars = EAknSCTLowerCase;
       
 18038                 }
       
 18039             }
       
 18040         else
       
 18041             {
       
 18042             if (iMode == ELatin)
       
 18043                 {
       
 18044                 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 18045                     {
       
 18046                     sctChars = EAknSCTChiLatinInputModes;
       
 18047                     }
       
 18048                 else
       
 18049                     {
       
 18050                     if (iQwertyInputMode)
       
 18051                         {
       
 18052                         sctChars = EAknSCTQwerty;
       
 18053                         afterSctChars = EAknSCTFullCase;                        
       
 18054                         }
       
 18055                     else
       
 18056                         {                                           
       
 18057                         sctChars = EAknSCTUpperCase;
       
 18058                         afterSctChars = EAknSCTFullCase;
       
 18059                         if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
 18060                             {
       
 18061                             sctChars = EAknSCTLowerCase;
       
 18062                             }
       
 18063                         }
       
 18064                     }
       
 18065                 }
       
 18066             else if (iMode == ENumber||iMode == ENativeNumber)
       
 18067                 {
       
 18068                 sctChars = EAknSCTNumeric;
       
 18069                 if ( ((iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) ||
       
 18070                       (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap)) &&
       
 18071                       !IsOnlyHalfWidthCharacterPermitted() )
       
 18072                     {
       
 18073                     sctChars = EAknSCTLowerCase;
       
 18074                     afterSctChars = EAknSCTFullCase;
       
 18075                     }
       
 18076                 }
       
 18077             else if (iMode == EHiraganaKanji)
       
 18078                 {
       
 18079                 sctChars = EAknSCTFullCase;
       
 18080                 }
       
 18081             else if(iMode == EKatakana)
       
 18082                 {
       
 18083                 sctChars = EAknSCTHalfCase;
       
 18084                 afterSctChars = EAknSCTFullCase;
       
 18085                 }
       
 18086             }
       
 18087 
       
 18088         SetFlag(EFlagForegroundUIComponentVisible);
       
 18089 
       
 18090         TBool showAnotherTable = EFalse;
       
 18091         if (IsFeatureSupportedJapanese())
       
 18092             {
       
 18093             if (sctChars == EAknSCTFullCase)
       
 18094                 {
       
 18095                 if (!IsOnlyFullWidthCharacterPermitted())
       
 18096                     {
       
 18097                     showAnotherTable = ETrue;
       
 18098                     }
       
 18099                 }
       
 18100             else if (sctChars == EAknSCTHalfCase || sctChars == EAknSCTUpperCase 
       
 18101                   || sctChars == EAknSCTLowerCase)
       
 18102                 {
       
 18103                 if (!IsOnlyHalfWidthCharacterPermitted() 
       
 18104                  && !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
 18105                     {
       
 18106                     showAnotherTable = ETrue;
       
 18107                     }
       
 18108                 }
       
 18109             }
       
 18110 #ifdef RD_SCALABLE_UI_V2     
       
 18111         if( iFepFullyConstructed && !iFepPluginManager->IsGlobleNotes())
       
 18112             {
       
 18113              if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
 18114                  iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
 18115                  iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)
       
 18116                 {
       
 18117                  SetStopProcessFocus(ETrue, EFalse);
       
 18118                 iFepPluginManager->SetMenuState();            
       
 18119                 }            
       
 18120              else if (!iFepPluginManager->IsGlobleNotes())
       
 18121                 {
       
 18122                 iFepPluginManager->ClosePluginInputUiL( ETrue );
       
 18123                 }
       
 18124             }
       
 18125 #endif  
       
 18126 
       
 18127         TBool lockNumericKeys = ( iPtiEngine->IsQwertyBasedMode(iPtiEngine->InputMode())) 
       
 18128         #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18129                             || ( iPtiEngine->InputMode() == EPtiEngineHalfQwerty ) ||
       
 18130                             ( iPtiEngine->InputMode() == EPtiEngineHalfQwertyPredictive ) 
       
 18131         #endif                            
       
 18132                             ;
       
 18133         TUid fepUid = CCoeEnv::Static()->FepUid();
       
 18134 
       
 18135         if(IsAbleToLaunchSmiley())
       
 18136             {
       
 18137             if(aShowSctMode == EShowSmileyFirst)
       
 18138                 {
       
 18139                 sctChars |= EAknCharMapEmotionFirst;
       
 18140                 }
       
 18141             else
       
 18142                 {
       
 18143                 sctChars |= EAknCharMapEmotionUse;
       
 18144                 }
       
 18145             }
       
 18146         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 18147         
       
 18148 		if (iUiInterface->CharMapDialogL(
       
 18149 			sctChars, 
       
 18150 			specialChars, 
       
 18151 			charMap,
       
 18152 			lockNumericKeys,
       
 18153             aShowSctMode==EShowPctFirst,
       
 18154 			!IsAbleToLaunchPCT(),
       
 18155 			showAnotherTable,
       
 18156 			afterSctChars,
       
 18157 			currentEditorSCTResId,
       
 18158 			disableRecentItemRow))
       
 18159             {
       
 18160             PrepareFepAfterDialogExitL(fepUid);
       
 18161             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
 18162 
       
 18163 #ifdef RD_SCALABLE_UI_V2 
       
 18164             
       
 18165             if( iFepFullyConstructed && iFepPluginManager)
       
 18166                 {
       
 18167                  if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
 18168                      iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
 18169                      iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)
       
 18170                     {
       
 18171                     SetStopProcessFocus(EFalse);
       
 18172                     }            
       
 18173                  else
       
 18174                     {
       
 18175                     HandleChangeInFocus();
       
 18176                     }
       
 18177                 }
       
 18178             else
       
 18179                 {
       
 18180                 HandleChangeInFocus();
       
 18181                 }   
       
 18182             // Set the flag, not change focus for next.
       
 18183             iDisalbleFocusChangeForSCT = ETrue;           
       
 18184 #endif
       
 18185 
       
 18186             //Removes auto-complition part if SCT is launched and any special character is selected 
       
 18187 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18188             if( specialChars.Length() > 0 )
       
 18189                 {
       
 18190             	RemoveSuggestedAdvanceCompletionL();
       
 18191                 }
       
 18192 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 18193             TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
 18194             for ( TInt ii = 0; ii < specialChars.Length(); ii++)
       
 18195                 {
       
 18196                 charAsDesc[0]=(TText)specialChars[ii];
       
 18197 
       
 18198                 if (iInputCapabilities.SupportsSecretText())
       
 18199                     {
       
 18200                     TChar ch = charAsDesc[0];
       
 18201                     if (ch == TText(0x000A) || ch == TText(CEditableText::EParagraphDelimiter))
       
 18202                         // 0x000A is ascii, EParagraphDelimiter is unicode - future
       
 18203                         // proofs against sct changing to unicode
       
 18204                         ch = EKeyEnter;
       
 18205                     if (CharIsValidInEditor(ch))
       
 18206                         {
       
 18207                         //we receive an extra key press if we simulate a key that is also a device key
       
 18208                         if (ch.IsDigit() || TUint(ch) == EStarKeyUnicodeValue 
       
 18209                          || TUint(ch) == EHashKeyUnicodeValue)
       
 18210                             SetFlag(EFlagPassNextKey);
       
 18211                         SimulateKeyEventL(ch);
       
 18212                         }
       
 18213                     }
       
 18214                 else
       
 18215                     {
       
 18216                     if (charAsDesc[0] == TText(0x000A)) // 0x000A is line feed
       
 18217                         {
       
 18218                         charAsDesc[0] = CEditableText::EParagraphDelimiter;
       
 18219                         }
       
 18220                         
       
 18221                     if (CharIsValidInEditor(charAsDesc[0]))
       
 18222                         {
       
 18223                         TCursorSelection cursorSelection(0,0);
       
 18224                         if ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) && iMode == ELatin 
       
 18225                           && !WesternPredictive())
       
 18226                             {
       
 18227                             TInt edSize = 
       
 18228                                    iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 18229                             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 18230                             if (iUncommittedText.iCursorPos < edSize 
       
 18231                              && iUncommittedText.Length() == 0)
       
 18232                                 {
       
 18233                                 cursorSelection = TCursorSelection(iUncommittedText.iCursorPos + 1,
       
 18234                                                                    iUncommittedText.iAnchorPos);
       
 18235                                 }
       
 18236                             }
       
 18237                         if (EditorState())
       
 18238                             {
       
 18239                             if (charAsDesc[0] == CEditableText::EParagraphDelimiter)
       
 18240                                 {
       
 18241                                 // This is line feed character. Post it to editor and let it decide
       
 18242                                 // if it is valid.
       
 18243                                  if (!(iAknEditorFlags & EAknEditorFlagFindPane) 
       
 18244                                     && specialChars.Length() == 1)
       
 18245                                     { 
       
 18246 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18247                                     CommitInlineEditL();                                    
       
 18248 #endif
       
 18249                                    
       
 18250                                     SimulateKeyEventL(EKeyEnter);   
       
 18251                                     SimulateKeyEventL(EKeyF19); // Asyncronous case update                                                                                              
       
 18252                                     }
       
 18253                                 }                                                        
       
 18254                             else
       
 18255                                 {                                                                                                                                   
       
 18256                                 if (replace)
       
 18257                                     {
       
 18258                                     TKeyEvent delKey = {8, EStdKeyBackspace, 1, 0};        
       
 18259                                     CCoeEnv::Static()->SimulateKeyEventL(delKey, EEventKey);                                                                
       
 18260                                     }                               
       
 18261                                 InsertTextFromDialogL(charAsDesc, cursorSelection);
       
 18262 //There may be several char to be inserted, need disable Focus change to avoid multi-focus change.
       
 18263 #ifdef RD_SCALABLE_UI_V2 
       
 18264                                 iDisalbleFocusChangeForSCT = ETrue;
       
 18265 #endif
       
 18266                                 }
       
 18267                             // Clear dead key, vowel sequence and vietnamese tone mark states.                         
       
 18268                             iPtiEngine->HandleCommandL(EPtiCommandGetAndClearLastVietnameseChar, 
       
 18269                                                        NULL);
       
 18270                             iPtiEngine->HandleCommandL(EPtiCommandClearVowelSeq, 
       
 18271                                                        NULL);
       
 18272                             iPtiEngine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar, 
       
 18273                                                        NULL);                            
       
 18274                             }
       
 18275                         }
       
 18276                     }
       
 18277                 }
       
 18278             }
       
 18279         else
       
 18280             {
       
 18281             iClosePeninputUi = EFalse;
       
 18282             iStopProcessFocus = EFalse;                   
       
 18283             }
       
 18284             
       
 18285         PrepareFepAfterDialogExitL(fepUid);
       
 18286         }
       
 18287     }
       
 18288 
       
 18289 /**
       
 18290  * Queries supportting of SecretText
       
 18291  *
       
 18292  * @since 2.6
       
 18293  * @return ETrue if SecretText was supported
       
 18294  */
       
 18295 TBool CAknFepManager::IsSupportsSecretText() const
       
 18296     {
       
 18297     TBool bSecret = iInputCapabilities.SupportsSecretText();
       
 18298     if( !bSecret )
       
 18299         {
       
 18300         //test java editor
       
 18301         MObjectProvider* mop = iInputCapabilities.ObjectProvider();            	
       
 18302         if ( mop )
       
 18303            {
       
 18304             CAknExtendedInputCapabilities* extendedInputCapabilities;
       
 18305             extendedInputCapabilities = mop->MopGetObject( extendedInputCapabilities );
       
 18306             if ( extendedInputCapabilities ) 
       
 18307                 {
       
 18308                 TUint constraints = extendedInputCapabilities->MIDPConstrainst();
       
 18309                 if( constraints & 0x10000 )
       
 18310                     {
       
 18311                     bSecret = ETrue;
       
 18312                     }
       
 18313                 }
       
 18314             }
       
 18315         }
       
 18316     
       
 18317     return bSecret;
       
 18318     }
       
 18319 
       
 18320 void CAknFepManager::SendEventsToPluginManL( TInt aEventType, TInt aEventData )
       
 18321     {
       
 18322 #ifdef RD_SCALABLE_UI_V2
       
 18323     if ( iFepFullyConstructed )
       
 18324         {
       
 18325         iFepPluginManager->HandleEventsFromFepL( aEventType, aEventData );
       
 18326         }
       
 18327 #endif //RD_SCALABLE_UI_V2
       
 18328     }
       
 18329     
       
 18330 void CAknFepManager::UpdateCangJieState(TInt aNewMode)
       
 18331     {
       
 18332     CAknFepUIManagerChinese* fepUiMgr = STATIC_CAST(CAknFepUIManagerChinese*, 
       
 18333                                              iLangMan->GetFepUI(ECangJie, ENoneWidthChar, EFalse));
       
 18334     
       
 18335     if (aNewMode >= 0)
       
 18336         {
       
 18337         if ( fepUiMgr )
       
 18338             {
       
 18339             fepUiMgr->UpdateCangJieState();
       
 18340             }
       
 18341         
       
 18342         // Store CangJie settings into the sharedata
       
 18343         iSharedDataInterface->SetCangJieMode(aNewMode);            
       
 18344         }
       
 18345     }
       
 18346 
       
 18347 TInt CAknFepManager::LaunchCangJieOptionDlgL()
       
 18348     {
       
 18349     // Get the CangJie level from the GS
       
 18350     TInt currentLevel = iSharedDataInterface->CangJieMode();
       
 18351     
       
 18352     if ((currentLevel != ECangJieNormal) 
       
 18353     && (currentLevel != ECangJieEasy) 
       
 18354     && (currentLevel != ECangJieAdvanced))
       
 18355         return KErrGeneral;
       
 18356 
       
 18357     // Launch the CangJie setting menu
       
 18358     CDesCArrayFlat* items = CCoeEnv::Static()->ReadDesC16ArrayResourceL(R_AVKON_CANGJIE_OPTIONS_LBX);
       
 18359     CleanupStack::PushL(items);
       
 18360 
       
 18361     TUid fepUid = CCoeEnv::Static()->FepUid();   
       
 18362     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 18363 	TInt ret = iUiInterface->LaunchCangJieOptionDlgL(
       
 18364         R_AVKON_CANGJIE_MODE_OPTIONS_SETTING_PAGE,
       
 18365         currentLevel,
       
 18366         items
       
 18367         );
       
 18368     PrepareFepAfterDialogExitL(fepUid);
       
 18369 
       
 18370     CleanupStack::PopAndDestroy(items);
       
 18371 
       
 18372     return ret ? currentLevel : KErrGeneral;
       
 18373     }
       
 18374 
       
 18375 GLDEF_C void AknFepPanic(TAknFepPanic aPanic)
       
 18376     {
       
 18377     User::Panic(_L("AKNFEP"),aPanic);
       
 18378     }
       
 18379 
       
 18380 /**
       
 18381  * Set Multitap timer value. 
       
 18382  *
       
 18383  * @since 3.0
       
 18384  * @param Value of KAknFepMultiTapTimer setting
       
 18385  */
       
 18386 void CAknFepManager::SetMultiTapTimer(const TInt aMultiTapTimer)
       
 18387     {
       
 18388     if (iMultiTapTimer != aMultiTapTimer)
       
 18389         {
       
 18390         iMultiTapTimer = aMultiTapTimer;
       
 18391         }
       
 18392     }
       
 18393 
       
 18394 /**
       
 18395  * Set Japanese Qwerty Flags value. 
       
 18396  *
       
 18397  * @since 3.0
       
 18398  * @param Value of KAknFepJapaneseSpecialCharFlag setting
       
 18399  */
       
 18400 void CAknFepManager::SetJapaneseQwertyFlags(const TInt aJapaneseQwertyFlags)
       
 18401     {
       
 18402     if (iJapaneseQwertyFlags != aJapaneseQwertyFlags)
       
 18403         {
       
 18404         iJapaneseQwertyFlags = aJapaneseQwertyFlags;
       
 18405         }
       
 18406     }
       
 18407 
       
 18408 /**
       
 18409  * Handle the Chr Key Monitor
       
 18410  * for Japanese variant only.
       
 18411  *
       
 18412  * @since 3.0
       
 18413  * @return KErrNone if succeed, KErrDied if failed
       
 18414  */
       
 18415 TInt CAknFepManager::HandleChrKeyMonitorCallback(TAny* aObj)
       
 18416     {
       
 18417     TRAPD(err, static_cast<CAknFepManager*>(aObj)->HandleChrKeyMonitorL());
       
 18418     if (err)
       
 18419         {
       
 18420         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 18421         return KErrDied;
       
 18422         }
       
 18423     return KErrNone;
       
 18424     }
       
 18425 
       
 18426 /**
       
 18427  * Handle the Chr Key Monitor
       
 18428  * for Japanese variant only.
       
 18429  *
       
 18430  * @since 3.0
       
 18431  */
       
 18432 void CAknFepManager::HandleChrKeyMonitorL()
       
 18433     {
       
 18434 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18435 #ifdef __HALF_QWERTY_KEYPAD        
       
 18436     if ( IsFlagSet(EFlagQwertyChrKeyDepressed) && 
       
 18437     		  IsFlagSet(EFlagNoActionDuringChrKeyPress) && 
       
 18438     		  (EPtiKeyboardHalfQwerty == KeyboardLayout() ) && 
       
 18439     		  ( iWesternPredictive || iMode == EPinyin || 
       
 18440     		     iMode == EStroke || iMode == EZhuyin ) )   
       
 18441     	{
       
 18442     	// Clear the chr key depressed flag
       
 18443     	TBool validchr = FepUI()->IsValidLongChrKeyPress();
       
 18444     	
       
 18445     	if(!validchr || !IsAbleToLaunchSCT() )
       
 18446     		{
       
 18447 			  FepUI()->HandleKeyL( EStdKeyLeftFunc, EShortKeyPress );    		
       
 18448 			  ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
 18449     		}
       
 18450     	else
       
 18451     		{
       
 18452     		// will launch SCT later
       
 18453     		iChrLongKeyPress = ETrue;	
       
 18454     		}	
       
 18455         
       
 18456     	}
       
 18457     	else
       
 18458 #endif   
       
 18459 #endif
       
 18460 	 if (IsFlagSet(EFlagQwertyChrKeyDepressed) && IsFlagSet(EFlagNoActionDuringChrKeyPress)
       
 18461      && iCurrentFepUI->IsValidShiftKeyPress())
       
 18462         {
       
 18463         // Timer cancel
       
 18464         iChrKeypressMonitor->Cancel();
       
 18465         // Commit characters
       
 18466         HandleChangeInFocus();
       
 18467         // Clear flags
       
 18468         ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
 18469         // Open editting menu
       
 18470         LaunchSelectModeMenuL();
       
 18471         }
       
 18472     }
       
 18473 
       
 18474 
       
 18475 // -----------------------------------------------------------------------------
       
 18476 // CAknFepManager::SetCursorSelectionL
       
 18477 // Set editor cursor selection.
       
 18478 // (other items were commented in a header).
       
 18479 // -----------------------------------------------------------------------------
       
 18480 //
       
 18481 void CAknFepManager::SetCursorSelectionL(const TCursorSelection& /*aCurSel*/, TBool /*aSyncCursor*/)
       
 18482     {
       
 18483     }
       
 18484 
       
 18485  TInt CAknFepManager::HandleResourceChangedCallback(TAny* aObj)
       
 18486 	{
       
 18487 	TRAPD(err, static_cast<CAknFepManager*>(aObj)->ResourceChangedTimeroutL());
       
 18488     if (err)
       
 18489         {
       
 18490         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 18491         return KErrNoMemory;
       
 18492         }
       
 18493     return KErrNone;
       
 18494 	}
       
 18495 
       
 18496 void CAknFepManager::ResourceChangedTimeroutL()
       
 18497     {
       
 18498     if(iCurrentFepUI)
       
 18499 	    {
       
 18500 	    iCurrentFepUI->ResourceChanged(1);	
       
 18501 	    }   
       
 18502     }
       
 18503 
       
 18504 
       
 18505 // -----------------------------------------------------------------------------
       
 18506 // pen related inplementation
       
 18507 // -----------------------------------------------------------------------------
       
 18508 #ifdef RD_SCALABLE_UI_V2
       
 18509 
       
 18510 // -----------------------------------------------------------------------------
       
 18511 // CAknFepManager::HandleLayoutChange
       
 18512 // Update plugin UI case mode.
       
 18513 // (other items were commented in a header).
       
 18514 // -----------------------------------------------------------------------------
       
 18515 //
       
 18516 void CAknFepManager::HandleResourceChange(TInt aType)
       
 18517     {
       
 18518     if(iCurrentFepUI)
       
 18519     	{
       
 18520         iAsyncResouceChanged.CallBack();
       
 18521     	}
       
 18522 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18523     if(iCandidatePopup && iPtiEngine && (aType == KEikDynamicLayoutVariantSwitch))        
       
 18524         {
       
 18525         //When there is a change of layout, the inline text position changes and hence the candidate 
       
 18526         //list position also needs to change accordingly.
       
 18527         //We need the editor to be brought back to focus, this is because we need the position of
       
 18528         //the inline text.
       
 18529         iCandidatePopup->UnFocus();
       
 18530         //Need to get the editor state back after it is brought back to focus.
       
 18531         TRAP_IGNORE( HandleChangeInFocusL()); 
       
 18532         
       
 18533         // Add candidate list control stack to get the layout change event
       
 18534         // after dialog control......
       
 18535         TRAP_IGNORE( iCandidatePopup->SetFocusAddStackReducePriorityL() );
       
 18536         
       
 18537         }
       
 18538 #endif		
       
 18539     TRAP_IGNORE(SendEventsToPluginManL( EPluginResourceChanged, aType ));
       
 18540     }   
       
 18541 void CAknFepManager::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
 18542     {
       
 18543     if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 18544         {
       
 18545         ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 18546         }
       
 18547    
       
 18548     if(aPointerEvent.iType == TPointerEvent::EDrag)
       
 18549     	{
       
 18550     	SetExtendedFlag(EExtendedFlagPointerEventTypeEDrag);
       
 18551     	}
       
 18552     if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
 18553         {
       
 18554     	ClearExtendedFlag(EExtendedFlagPointerEventTypeEDrag);
       
 18555 
       
 18556         // Remember last up-click in case it is needed for displaying
       
 18557         // stylus ccpu-menu.
       
 18558         iClickPoint = aPointerEvent.iPosition;
       
 18559         }    
       
 18560     }
       
 18561  
       
 18562 // -----------------------------------------------------------------------------
       
 18563 // CAknFepManager::HandleSelModeArrowKeyEventL
       
 18564 // Set text selection when tap on the arrow keys.
       
 18565 // (other items were commented in a header).
       
 18566 // -----------------------------------------------------------------------------
       
 18567 //
       
 18568 TBool CAknFepManager::HandleSelModeArrowKeyEventL(const TKeyEvent& aKeyEvent, 
       
 18569                                                   TEventCode aEventCode,
       
 18570                                                   TKeyResponse& aRetCode)
       
 18571     {
       
 18572     TCursorSelection currentEditorSelection(0,0);
       
 18573 	if(iInputCapabilities.FepAwareTextEditor())
       
 18574     	{
       
 18575     	iInputCapabilities.FepAwareTextEditor()->
       
 18576     		GetCursorSelectionForFep(currentEditorSelection);
       
 18577     	}    
       
 18578         
       
 18579 	if(!IsMfneEditor() &&
       
 18580 		(PluginInputMode() == EPluginInputModeItut ||
       
 18581 		 PluginInputMode() == EPluginInputModeFSQ)  &&
       
 18582 		 currentEditorSelection.Length() != 0)
       
 18583     	{
       
 18584     	
       
 18585         if ((aKeyEvent.iScanCode == EStdKeyLeftArrow) || (aKeyEvent.iScanCode == EStdKeyRightArrow)) 
       
 18586             {   
       
 18587             if (!(aKeyEvent.iModifiers & EModifierShift))
       
 18588                 {
       
 18589                 TKeyEvent ccpuStart = aKeyEvent;
       
 18590                 ccpuStart.iModifiers |= EModifierShift;
       
 18591                 ccpuStart.iModifiers |= EModifierRightShift;
       
 18592                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);        
       
 18593                 
       
 18594                 aRetCode = EKeyWasConsumed;
       
 18595                 return ETrue;
       
 18596                 }  
       
 18597             else
       
 18598                 {
       
 18599                 aRetCode = EKeyWasNotConsumed;
       
 18600                 return ETrue;              
       
 18601                 }               
       
 18602             }	
       
 18603     	}
       
 18604     aRetCode = EKeyWasNotConsumed;
       
 18605     return EFalse;    
       
 18606     }
       
 18607 
       
 18608 #else // !RD_SCALABLE_UI_V2
       
 18609 // -----------------------------------------------------------------------------
       
 18610 // CAknFepManager::HandleResourceChange
       
 18611 // Update plugin UI case mode.
       
 18612 // (other items were commented in a header).
       
 18613 // -----------------------------------------------------------------------------
       
 18614 //
       
 18615 void CAknFepManager::HandleResourceChange(TInt aType)
       
 18616     {
       
 18617     if (iFepFullyConstructed && Japanese() )
       
 18618         {
       
 18619         // Japaneseinput should handle the event of changing layout or screen.
       
 18620         FepUI()->ResourceChanged(aType);
       
 18621         }
       
 18622 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18623     if(iCandidatePopup && iPtiEngine && (aType == KEikDynamicLayoutVariantSwitch))        
       
 18624         {
       
 18625         //When there is a change of layout, the inline text position changes and hence the candidate 
       
 18626         //list position also needs to change accordingly.
       
 18627         //We need the editor to be brought back to focus, this is because we need the position of
       
 18628         //the inline text.
       
 18629         iCandidatePopup->UnFocus();
       
 18630         //Need to get the editor state back after it is brought back to focus.
       
 18631         TRAP_IGNORE(HandleChangeInFocusL());
       
 18632         //Can not do anything if FEP is not constructed fully
       
 18633         if(iFepFullyConstructed)
       
 18634             {
       
 18635             //Now we read the position of the inline text
       
 18636             TPoint  inlineEditorTl;
       
 18637             TPoint  inlineEditorBr;
       
 18638             TInt    height;
       
 18639             TInt    ascent;
       
 18640             TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
 18641             //  Popup Position for RTL
       
 18642             if(iLanguageCapabilities.iRightToLeftLanguage)
       
 18643                 documentOffset = 0;
       
 18644             //  Popup Position for RTL
       
 18645             TRAP_IGNORE( GetScreenCoordinatesL( inlineEditorTl, height, ascent, documentOffset ));
       
 18646             inlineEditorTl.iY -= height;
       
 18647             TRAP_IGNORE( GetScreenCoordinatesL( inlineEditorBr, height, ascent ));
       
 18648             
       
 18649             //Let the candidate list know about a change of resource and update the
       
 18650             //inline text rectangle.
       
 18651             //Now show the candidate list at the re-calculated position
       
 18652             iCandidatePopup->ShowAtNewPosition(TRect(inlineEditorTl,inlineEditorBr));
       
 18653             }
       
 18654         }
       
 18655 #endif		
       
 18656     }
       
 18657 
       
 18658 #endif //RD_SCALABLE_UI_V2    
       
 18659 
       
 18660 TDigitType CAknFepManager::LocalDigit()
       
 18661     {
       
 18662     return iLanguageCapabilities.iLocalDigitType;
       
 18663     }
       
 18664     
       
 18665 /**
       
 18666 * Returns ETrue if arabic indic digit setting is on. 
       
 18667 *
       
 18668 * @since 3.0
       
 18669 */
       
 18670 TBool CAknFepManager::ArabicIndicDigitsInUse() const
       
 18671     {
       
 18672     return (iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic);
       
 18673     }
       
 18674        
       
 18675 TBool CAknFepManager::EasternArabicIndicDigitsInUse() const
       
 18676     {
       
 18677     return (iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic);
       
 18678     }
       
 18679     
       
 18680 /**
       
 18681  *  Sets delayed commit on (predicitve word will be commited in 
       
 18682  *  next call to TryCloseUiL. This is needed because of Japanese ReadingTextL).
       
 18683  *
       
 18684  * @since 3.1
       
 18685  */
       
 18686 void CAknFepManager::SetDelayedCommit()
       
 18687     {
       
 18688     iCcpuMode |= ECcpuStataCommitPredictiveWord;
       
 18689     }
       
 18690 
       
 18691 // -----------------------------------------------------------------------------
       
 18692 // CAknFepManager::SetDefaultNumberMode
       
 18693 //
       
 18694 // Set default number mode for non-latin languagues
       
 18695 // 
       
 18696 // Copied from CGSLangModel::SetDefaultNumberMode
       
 18697 // -----------------------------------------------------------------------------
       
 18698 //
       
 18699 void CAknFepManager::SetDefaultNumberMode( TInt aMode, TInt aNbrModeType )
       
 18700     {
       
 18701     //As aMode comes from the UI, it can either be 0 or 1. This needs
       
 18702     //special handling for Indic mode as it has been defined as an enum
       
 18703     //constant and has a value of 2. This applies to any values defined
       
 18704     //in the enum and have a value > 1.
       
 18705     if ( aNbrModeType == ENbrModeTypeArabic ||
       
 18706          aNbrModeType == ENbrModeTypeEasternArabic )
       
 18707         {
       
 18708         iSharedDataInterface->SetDefaultNumberMode( KSettingsDefaultNumberMode, aMode );
       
 18709         }
       
 18710     else
       
 18711         {
       
 18712         iSharedDataInterface->SetDefaultNumberMode( KSettingsIndicDefaultNumberMode, aMode );
       
 18713         }
       
 18714 
       
 18715     TLocale locale;
       
 18716     if ( aMode == ENbrModeLatin )
       
 18717         {
       
 18718         locale.SetDigitType( EDigitTypeWestern );
       
 18719         }
       
 18720     else
       
 18721         {
       
 18722         //if aMode != EGSNbrModeLatin, then it should be either latin or arabic. However
       
 18723         //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use
       
 18724         //that constant for below comparison. Hence, need to depend on the 2nd param.
       
 18725         switch ( aNbrModeType )
       
 18726             {
       
 18727             case ENbrModeTypeArabic:
       
 18728                 locale.SetDigitType( EDigitTypeArabicIndic );
       
 18729                 break;
       
 18730             case ENbrModeTypeIndic:
       
 18731                 locale.SetDigitType( EDigitTypeDevanagari );
       
 18732                 break;
       
 18733             case ENbrModeTypeEasternArabic:
       
 18734                 locale.SetDigitType( EDigitTypeEasternArabicIndic );
       
 18735                 break;
       
 18736             default:
       
 18737                 break;
       
 18738             }
       
 18739         }
       
 18740 
       
 18741     locale.Set();
       
 18742     }
       
 18743 
       
 18744 // -----------------------------------------------------------------------------
       
 18745 // CAknFepManager::ResolveCurrentCandidateListIndex
       
 18746 //
       
 18747 // Calculates correct selection index for matches popup list.
       
 18748 // -----------------------------------------------------------------------------
       
 18749 //
       
 18750 TInt CAknFepManager::ResolveCurrentCandidateListIndex(CDesCArrayFlat* aCandList)
       
 18751     {
       
 18752     if (iPtiEngine && aCandList)
       
 18753         {           
       
 18754         TBuf<EMaximumFepWordLength> currentCand;
       
 18755     
       
 18756         currentCand.Copy(iPtiEngine->CurrentWord());    
       
 18757         for (TInt i = 0; i < aCandList->Count(); i++)
       
 18758             {
       
 18759             if (currentCand == aCandList->MdcaPoint(i))
       
 18760                 {
       
 18761                 if (i == aCandList->Count() - 1)
       
 18762                     {
       
 18763                     return 0;
       
 18764                     }
       
 18765                 return i + 1;
       
 18766                 }
       
 18767             }
       
 18768         }
       
 18769 
       
 18770     return 0;
       
 18771     }
       
 18772 
       
 18773 void CAknFepManager::AlignLogicalAndVisualCursorL( TTmDocPosSpec::TType aType, 
       
 18774                                                     TBool aToLeft )
       
 18775     {
       
 18776     if( !( iInputCapabilities.SupportsSecretText() ) )
       
 18777         {
       
 18778         if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 18779             IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 18780             {
       
 18781             CommitInlineEditL();
       
 18782             }
       
 18783 
       
 18784         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 18785             iInputCapabilities.FepAwareTextEditor();
       
 18786 
       
 18787 	    MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 18788         if( (docNavi || TextLayout()) && fepAwareTextEditor )
       
 18789             {
       
 18790             TTmDocPosSpec pos = DocPos();
       
 18791             pos.iType = aType;
       
 18792             TTmPosInfo2 info;
       
 18793             if (docNavi)
       
 18794             	{
       
 18795 	            docNavi->GetNextVisualCursorPos( pos, info, aToLeft );
       
 18796             	}
       
 18797             else
       
 18798             	{
       
 18799  	            TextLayout()->TagmaTextLayout().GetNextVisualCursorPos( pos, info, aToLeft );
       
 18800             	}
       
 18801             TCursorSelection curSel( info.iDocPos.iPos, info.iDocPos.iPos );
       
 18802             fepAwareTextEditor->SetCursorSelectionForFepL( curSel );
       
 18803             }
       
 18804         }
       
 18805     }
       
 18806 
       
 18807 void CAknFepManager::RemoveRephaCharacterL()
       
 18808     {
       
 18809     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 18810         iInputCapabilities.FepAwareTextEditor();
       
 18811     
       
 18812     if( fepAwareTextEditor )
       
 18813         {
       
 18814         TInt previousCharPos = 0;
       
 18815         TBool leftFlag = GetNextVisualLeftCharacter( previousCharPos );
       
 18816         
       
 18817         if( !leftFlag )
       
 18818             {
       
 18819             return;
       
 18820             }
       
 18821         
       
 18822         TCursorSelection curSel;
       
 18823         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 18824             
       
 18825         TInt lowerPos = curSel.LowerPos();
       
 18826         if( lowerPos > 1 )
       
 18827             {
       
 18828             const TInt rephaLength( 2 );
       
 18829             TBuf<rephaLength> previousCharacter;
       
 18830             previousCharacter.FillZ();
       
 18831             
       
 18832             fepAwareTextEditor->
       
 18833                 GetEditorContentForFep( previousCharacter, 
       
 18834                                         previousCharPos, rephaLength );
       
 18835             
       
 18836             if (rephaLength == previousCharacter.Length())
       
 18837                 {
       
 18838                 if( previousCharacter[0] == TAknFepUiIndicInputManager::RaCharacter( 
       
 18839                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 18840                     previousCharacter[1] == TAknFepUiIndicInputManager::Virama( 
       
 18841                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 18842                     {
       
 18843                     curSel.iAnchorPos = previousCharPos;
       
 18844                     curSel.iCursorPos = previousCharPos + rephaLength;
       
 18845                     
       
 18846                     // Remove the repha
       
 18847                     
       
 18848                     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 18849                         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 18850                         {
       
 18851                         CommitInlineEditL();
       
 18852                         }
       
 18853                     StartInlineEditL( curSel, previousCharacter, rephaLength, ETrue );
       
 18854                     UpdateInlineEditL( KNullDesC, 0 );
       
 18855                     CommitInlineEditL();
       
 18856     
       
 18857                     // Go to the visual right position of current ligature as the 
       
 18858                     // repha has been deleted.
       
 18859                     AlignLogicalAndVisualCursorL( TTmDocPosSpec::ELeading, EFalse );
       
 18860                     }
       
 18861                 }
       
 18862             }
       
 18863         }
       
 18864     }
       
 18865 
       
 18866 TBool CAknFepManager::IsRephaPresent()
       
 18867     {
       
 18868     TBool result = EFalse;
       
 18869     
       
 18870     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 18871         iInputCapabilities.FepAwareTextEditor();
       
 18872 
       
 18873     if( fepAwareTextEditor )
       
 18874         {
       
 18875         TCursorSelection curSel;
       
 18876         
       
 18877         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 18878         
       
 18879         TInt previousCharPos = 0;
       
 18880         TBool leftFlag = GetNextVisualLeftCharacter( previousCharPos );
       
 18881         
       
 18882         if( !leftFlag )
       
 18883             {
       
 18884             return result;
       
 18885             }
       
 18886 
       
 18887         TInt lowerPos = curSel.LowerPos();
       
 18888         if( lowerPos > 1 )
       
 18889             {
       
 18890             const TInt rephaLength( 2 );
       
 18891             TBuf<rephaLength> previousCharacter;
       
 18892             previousCharacter.FillZ();
       
 18893             
       
 18894             fepAwareTextEditor->
       
 18895                 GetEditorContentForFep( previousCharacter, 
       
 18896                                         previousCharPos, rephaLength );
       
 18897 
       
 18898             // Verify whether the length of the string is equal to the length 
       
 18899             // of repha before doing further checks.
       
 18900             if( previousCharacter.Length() == rephaLength )
       
 18901                 {               
       
 18902                 if( previousCharacter[0] == TAknFepUiIndicInputManager::RaCharacter( 
       
 18903                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 18904                     previousCharacter[1] == TAknFepUiIndicInputManager::Virama( 
       
 18905                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 18906                     {
       
 18907                     result = ETrue;
       
 18908                     }
       
 18909                 }
       
 18910             }
       
 18911         }
       
 18912         
       
 18913     return result;
       
 18914     }
       
 18915     
       
 18916 TText CAknFepManager::PreviousToPreviousChar( TBool aContextSensitive )
       
 18917     {
       
 18918     TBuf<ESingleCharacter> prevToPrevChar( ESingleCharacter );
       
 18919     prevToPrevChar.FillZ();
       
 18920 
       
 18921     if( !aContextSensitive )
       
 18922         {
       
 18923         TTmDocPosSpec pos = DocPos();
       
 18924         
       
 18925         // Pos=0 means it is before the first character and there is no previous character
       
 18926         if (pos.iPos > 0 ) 
       
 18927             {
       
 18928             if( iInputCapabilities.FepAwareTextEditor() )
       
 18929                 {
       
 18930                 iInputCapabilities.FepAwareTextEditor()->
       
 18931                     GetEditorContentForFep( prevToPrevChar, pos.iPos - 1, ESingleCharacter );
       
 18932                 }
       
 18933             }
       
 18934         }
       
 18935     else
       
 18936         {
       
 18937         TCursorSelection curSel;
       
 18938         
       
 18939         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 18940             iInputCapabilities.FepAwareTextEditor();
       
 18941         
       
 18942         if( fepAwareTextEditor )
       
 18943             {
       
 18944             fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 18945             TInt lowerpos = curSel.LowerPos();
       
 18946 
       
 18947             if( lowerpos > 1 )
       
 18948                 {
       
 18949                 fepAwareTextEditor->
       
 18950                     GetEditorContentForFep( prevToPrevChar, lowerpos - 2, ESingleCharacter );
       
 18951                 }
       
 18952             }
       
 18953         }
       
 18954     if (prevToPrevChar.Length())
       
 18955         return prevToPrevChar[0];
       
 18956     else
       
 18957         return NULL;
       
 18958     }
       
 18959 
       
 18960 void CAknFepManager::RemoveRakarCharacterL()
       
 18961     {
       
 18962     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 18963         iInputCapabilities.FepAwareTextEditor();
       
 18964     
       
 18965     if( fepAwareTextEditor )
       
 18966         {
       
 18967         TCursorSelection curSel;
       
 18968             
       
 18969         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 18970         
       
 18971         TInt lowerpos = curSel.LowerPos();
       
 18972 
       
 18973         if( lowerpos > 1 )
       
 18974             {
       
 18975             const TInt rakarLength( 2 );
       
 18976             TBuf<rakarLength> buffer;
       
 18977             buffer.FillZ();
       
 18978 
       
 18979             fepAwareTextEditor->
       
 18980                 GetEditorContentForFep( buffer, lowerpos - rakarLength, rakarLength );
       
 18981             
       
 18982             if (rakarLength == buffer.Length())
       
 18983                 {
       
 18984                 if( buffer[0] == TAknFepUiIndicInputManager::Virama( 
       
 18985                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 18986                     buffer[1] == TAknFepUiIndicInputManager::RaCharacter( 
       
 18987                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 18988                     {
       
 18989                     curSel.iAnchorPos = lowerpos - rakarLength;
       
 18990                     curSel.iCursorPos = lowerpos;
       
 18991                     
       
 18992                     // Remove the repha
       
 18993                     
       
 18994                     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 18995                         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 18996                         {
       
 18997                         CommitInlineEditL();
       
 18998                         }
       
 18999                     StartInlineEditL( curSel, buffer, rakarLength, ETrue );
       
 19000                     UpdateInlineEditL( KNullDesC, 0 );
       
 19001                     CommitInlineEditL();
       
 19002                     }
       
 19003                 }
       
 19004             }
       
 19005         }
       
 19006     }
       
 19007 
       
 19008 /**
       
 19009  * Returns the status of predictive input.
       
 19010  *
       
 19011  *  @since 3.2
       
 19012  *  @return ETrue is available predictive input.
       
 19013  */
       
 19014 TBool CAknFepManager::IsAbleToChangePrediction() const
       
 19015     {
       
 19016     TBool ret = EFalse;
       
 19017     if (!(iAknEditorFlags & EAknEditorFlagNoT9))
       
 19018         {
       
 19019         if (iMode == EHiraganaKanji)
       
 19020             {
       
 19021             if (HasJapanesePredictionInputMode())
       
 19022                 {
       
 19023                 ret = ETrue;
       
 19024                 }
       
 19025             }
       
 19026         else
       
 19027             {
       
 19028             ret = ETrue;
       
 19029             }
       
 19030         }
       
 19031     return ret;
       
 19032     }
       
 19033 
       
 19034 TLanguage CAknFepManager :: GetInputLanguageFromSharedDataInterface()
       
 19035 {
       
 19036     return ((TLanguage)(iSharedDataInterface->InputTextLanguage()));
       
 19037 }
       
 19038     
       
 19039     
       
 19040 void CAknFepManager::DeactivatePredicitveWordAndMoveCursorL()
       
 19041     {
       
 19042     if (WesternPredictive())
       
 19043         {           
       
 19044         TWesternNaviEvent naviEvent = ERightNaviEvent;
       
 19045     
       
 19046         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 19047             {
       
 19048             naviEvent = ELeftNaviEvent;     
       
 19049             }
       
 19050 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 19051 		// This function is called at time of Cut/Copy command
       
 19052 		// TryCloseUiL will remove the auto completion part
       
 19053 		// To adjust the visual cursor position commit the text with
       
 19054 		// auto completion part.  
       
 19055 		if( IsAutoCompleteOn()) 
       
 19056 			{
       
 19057 			TInt tailLength = 0;
       
 19058 			iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
 19059 
       
 19060 			if( tailLength > 0)
       
 19061 				{
       
 19062 				// Sync the key sequence and editor text.	
       
 19063 				iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );			
       
 19064 				}
       
 19065 			}
       
 19066 #endif
       
 19067     
       
 19068         // Find the visual left/right end of the current word
       
 19069         TTmDocPosSpec pos;
       
 19070         GetAvkonDefinedVisualLimitsOfSelection(
       
 19071                iUncommittedText, naviEvent, pos, NULL );
       
 19072                
       
 19073         TryCloseUiL();
       
 19074     
       
 19075         // Position should be dis-ambiguated based on last navigation and direction of blocks.
       
 19076         AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( pos, naviEvent );
       
 19077 
       
 19078         SetCursorPositionL( pos );
       
 19079 
       
 19080         iCaseMan->UpdateCase(ENullNaviEvent);       
       
 19081         }
       
 19082     }
       
 19083 
       
 19084 
       
 19085 // -----------------------------------------------------------------------------
       
 19086 // CAknFepManager::EditorCcpuStatus
       
 19087 //
       
 19088 // Returns the Ccpu status of given editor state as a flag combination.
       
 19089 // -----------------------------------------------------------------------------
       
 19090 //
       
 19091 TInt CAknFepManager::EditorCcpuStatus(CAknEdwinState* aEdwinState)
       
 19092     {
       
 19093     TInt ret = 0;
       
 19094                                             
       
 19095     if (aEdwinState && aEdwinState->CcpuState())
       
 19096         {
       
 19097         if (aEdwinState->CcpuState()->CcpuCanCopy())
       
 19098             {
       
 19099             ret |=  ECcpuStatusFlagCanCopy;
       
 19100             }
       
 19101         if (aEdwinState->CcpuState()->CcpuCanCut()) 
       
 19102             {
       
 19103             ret |=  ECcpuStatusFlagCanCut;
       
 19104             }
       
 19105         if (aEdwinState->CcpuState()->CcpuCanPaste())               
       
 19106             {
       
 19107             ret |=  ECcpuStatusFlagCanPaste;                    
       
 19108             }
       
 19109         }                 
       
 19110     return ret; 
       
 19111     }
       
 19112     
       
 19113 void CAknFepManager::NewLigatureL( const TDesC& aText )
       
 19114     {
       
 19115     if( !iInputCapabilities.SupportsSecretText() && 
       
 19116         ( EditorHasFreeSpace() || 
       
 19117             IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) ) )
       
 19118         {
       
 19119         if ( iFepManState == EAknFepStateInitial ) //multitapping
       
 19120             {
       
 19121             if ( !IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19122                 {
       
 19123                 ClearFlag( EFlagLineFeedCharacter );
       
 19124                 StartInlineEditL( aText );
       
 19125                 SetFlag( EFlagInsideMultitapInlineEditingTransaction );
       
 19126                 SetFlag( EFlagInsideInlineEditingTransaction );
       
 19127                 }
       
 19128             }
       
 19129         }
       
 19130     }
       
 19131 
       
 19132 
       
 19133 
       
 19134 // -----------------------------------------------------------------------------
       
 19135 // CAknFepManager::CancelCcpuMode
       
 19136 //
       
 19137 // Cancels the copy / cut mode initiated from editing options -submenu.
       
 19138 // -----------------------------------------------------------------------------
       
 19139 //
       
 19140 void CAknFepManager::CancelCcpuMode()
       
 19141     {
       
 19142     iIndicator->SetCopyMode(EFalse);
       
 19143     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateCopy | ECcpuStateStartCut | ECcpuStateCut))
       
 19144         {
       
 19145         iUiInterface->DeleteSoftkeys();    
       
 19146         }
       
 19147     
       
 19148     ResetCcpuFlags();                       
       
 19149     }
       
 19150 
       
 19151 // -----------------------------------------------------------------------------
       
 19152 // CAknFepManager::CancelShiftKeyTimer
       
 19153 //
       
 19154 // Cancels shift key timer.
       
 19155 // -----------------------------------------------------------------------------
       
 19156 //
       
 19157 void CAknFepManager::CancelShiftKeyTimer()
       
 19158     {
       
 19159     ClearFlag(EFlagShiftKeyDepressed);
       
 19160     if (iShiftKeypressMonitor)
       
 19161         {
       
 19162         iShiftKeypressMonitor->Cancel();    
       
 19163         }
       
 19164     }
       
 19165 
       
 19166 void CAknFepManager::RemoveTextFromEditorL( TInt aNumOfCharacters, 
       
 19167                                             TInt aPos /*= 0*/,
       
 19168                                             TBool aIsToAlignCursor /* = ETrue */)
       
 19169 	{
       
 19170     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 19171         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19172         {
       
 19173         // Update the inline buffer with NULL descriptor.
       
 19174         // Inline buffer can be only at position 0, i.e. 
       
 19175         // where the cursor stands.
       
 19176         if( aNumOfCharacters == UncommittedText().Length()
       
 19177              && aPos == 0 )
       
 19178             {
       
 19179             UpdateInlineEditL( KNullDesC, 0 );
       
 19180             }
       
 19181         CommitInlineEditL();
       
 19182         }
       
 19183     else
       
 19184         {
       
 19185         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19186             iInputCapabilities.FepAwareTextEditor();
       
 19187 
       
 19188         if( fepAwareTextEditor && aPos >= 0 )
       
 19189             {
       
 19190             // Get the previous cursor position.
       
 19191             TCursorSelection cursorSelPrevious;
       
 19192             fepAwareTextEditor->GetCursorSelectionForFep( cursorSelPrevious );
       
 19193 
       
 19194             // Place the cursor at the desired position.
       
 19195             TCursorSelection sel( cursorSelPrevious.iCursorPos - aPos, 
       
 19196                             cursorSelPrevious.iCursorPos - aPos );
       
 19197         	fepAwareTextEditor->SetCursorSelectionForFepL( sel );
       
 19198 
       
 19199             // Set cursor span on previous N characters
       
 19200             if ( sel.iAnchorPos >= aNumOfCharacters )
       
 19201                 {
       
 19202                 sel.iAnchorPos -= aNumOfCharacters;
       
 19203 
       
 19204                 // get text to clear
       
 19205                 TBuf<EMaximumFepWordLength> bufToClear;
       
 19206                 fepAwareTextEditor->GetEditorContentForFep( bufToClear, sel.iAnchorPos, 
       
 19207                                                             aNumOfCharacters );
       
 19208 
       
 19209                 // delete the character with an inline edit
       
 19210                 StartInlineEditL( sel, bufToClear, aNumOfCharacters, EFalse );
       
 19211                 UpdateInlineEditL( KNullDesC, 0 );
       
 19212                 CommitInlineEditL();
       
 19213                 
       
 19214                 if( aIsToAlignCursor )
       
 19215                     {
       
 19216                     // Move the cursor to the original position considering the 
       
 19217                     // aNumOfCharacters
       
 19218                     cursorSelPrevious.iCursorPos -= aNumOfCharacters;
       
 19219                     cursorSelPrevious.iAnchorPos = cursorSelPrevious.iCursorPos;
       
 19220                     fepAwareTextEditor->SetCursorSelectionForFepL( cursorSelPrevious );
       
 19221                     }
       
 19222                 }        
       
 19223             }        
       
 19224         }
       
 19225     }
       
 19226 
       
 19227 #ifdef RD_MARATHI
       
 19228 
       
 19229 TBool CAknFepManager::IsChandraAPresentL()
       
 19230     {
       
 19231     TBool result = EFalse;
       
 19232 
       
 19233     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19234 		iInputCapabilities.FepAwareTextEditor();
       
 19235 
       
 19236 	if( fepAwareTextEditor )
       
 19237 		{
       
 19238 		TCursorSelection curSel;
       
 19239 		
       
 19240 		fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19241 		
       
 19242 		TInt lowerpos = curSel.LowerPos();
       
 19243 
       
 19244         TInt chandraALength = 2;
       
 19245         TBuf<2> buf;
       
 19246 	    TAknFepUiIndicInputManager::GetChandraA( buf );
       
 19247 
       
 19248 		if( lowerpos > ( chandraALength - 1 ) )
       
 19249 			{
       
 19250 			TBuf<2>previousCharacter;
       
 19251 
       
 19252 			fepAwareTextEditor->GetEditorContentForFep( 
       
 19253                 previousCharacter, lowerpos-chandraALength, chandraALength );
       
 19254 			
       
 19255 			if( buf.CompareC( previousCharacter ) == 0 )
       
 19256 			    {
       
 19257 			    // Chandra-A found
       
 19258 			    result = ETrue;
       
 19259 			    }
       
 19260 			}
       
 19261 		}
       
 19262     return result;
       
 19263 	}
       
 19264 
       
 19265 TBool CAknFepManager::IsEyeLashRaPresentL()
       
 19266     {
       
 19267     TBool result = EFalse;
       
 19268 
       
 19269     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19270 		iInputCapabilities.FepAwareTextEditor();
       
 19271 
       
 19272 	if( fepAwareTextEditor )
       
 19273 		{
       
 19274 		TCursorSelection curSel;
       
 19275 		
       
 19276 		fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19277 		
       
 19278 		TInt lowerpos = curSel.LowerPos();
       
 19279 
       
 19280         
       
 19281         TBuf<3> buf;
       
 19282 	    TAknFepUiIndicInputManager::GetEyeLashRa( buf, 
       
 19283 	                                    (TLanguage)iLanguageCapabilities.iInputLanguageCode );
       
 19284         TInt eyeLashRaLength = buf.Length();
       
 19285 
       
 19286 		if( ( lowerpos - eyeLashRaLength ) >= 0 )
       
 19287 			{
       
 19288 			TBuf<3>previousCharacter;
       
 19289 
       
 19290 			fepAwareTextEditor->GetEditorContentForFep( 
       
 19291                 previousCharacter, lowerpos-eyeLashRaLength, eyeLashRaLength );
       
 19292 			
       
 19293 			if( previousCharacter.Length() >=2 && 
       
 19294 			    buf.CompareC( previousCharacter ) == 0 )
       
 19295 			    {
       
 19296 			    // EyeLashRa found
       
 19297 			    result = ETrue;
       
 19298 			    }
       
 19299 			}
       
 19300 		}
       
 19301     return result;
       
 19302 	}
       
 19303 
       
 19304 #endif // RD_MARATHI
       
 19305 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 19306 void CAknFepManager::RemoveSuggestedCompletionL()
       
 19307 {	
       
 19308 	if(iPtiEngine->InputMode() == EPtiEngineWordCompletion && 
       
 19309 	   IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
 19310 		{
       
 19311 			TBuf<CAknFepManager::EMaximumFepWordLength> currentText = iPtiEngine->CurrentWord();
       
 19312 			if(currentText.Length() > iPtiEngine->CurrentInputSequence().Length())
       
 19313 				{
       
 19314 				currentText.SetLength(iPtiEngine->CurrentInputSequence().Length());
       
 19315 				iPtiEngine->SetCurrentWord(currentText);
       
 19316 	    		UpdateInlineEditL(currentText,currentText.Length()); 
       
 19317    	            TransferFepStateToEditorL();
       
 19318 				}
       
 19319 			
       
 19320 		}
       
 19321 }
       
 19322 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19323 
       
 19324 
       
 19325 // -----------------------------------------------------------------------------
       
 19326 // CAknFepManager::ExtendedInputCapabilities
       
 19327 //
       
 19328 // Returns the extended input bapabilities bitvector.
       
 19329 // -----------------------------------------------------------------------------
       
 19330 //
       
 19331 TUint CAknFepManager::ExtendedInputCapabilities() const
       
 19332     {
       
 19333     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 19334 
       
 19335     if ( mop && iInputCapabilities.FepAwareTextEditor() )//IsFepAwareTextEditor()
       
 19336 		{
       
 19337 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 19338 		mop->MopGetObject( extendedInputCapabilities );
       
 19339 
       
 19340 		if ( extendedInputCapabilities ) 
       
 19341 			{
       
 19342 			return extendedInputCapabilities->Capabilities();
       
 19343 			}
       
 19344 		} 
       
 19345 		
       
 19346     return 0;		          
       
 19347     }
       
 19348 
       
 19349 
       
 19350 #ifdef RD_SCALABLE_UI_V2         
       
 19351 // -----------------------------------------------------------------------------
       
 19352 // CAknFepManager::LaunchStylusCcpuMenuL
       
 19353 //
       
 19354 // Displays stylus ccpu-menu.
       
 19355 // -----------------------------------------------------------------------------
       
 19356 //    
       
 19357 void CAknFepManager::LaunchStylusCcpuMenuL(TPoint &aClickPoint)
       
 19358     {
       
 19359     const TInt KItemCopy  = 0x01;
       
 19360     const TInt KItemCut   = 0x02;
       
 19361     const TInt KItemPaste = 0x04;
       
 19362     
       
 19363     delete iStylusCcpuMenu;
       
 19364     iStylusCcpuMenu = NULL;    
       
 19365      
       
 19366     // It is assume that this method is called only if there is selected
       
 19367     // text in suitable editor, ie. there will be at least "copy"-item available.
       
 19368     TInt items = KItemCopy;    
       
 19369         
       
 19370     CAknEdwinState* editorState = EditorState();
       
 19371     if (editorState && editorState->CcpuState())
       
 19372         {              
       
 19373         if (editorState->CcpuState()->CcpuCanCut())
       
 19374             {
       
 19375             items |= KItemCut;
       
 19376             }
       
 19377         if (editorState->CcpuState()->CcpuCanPaste())
       
 19378             {
       
 19379             items |= KItemPaste;
       
 19380             }                    
       
 19381         }        
       
 19382     
       
 19383     if (items)
       
 19384         {
       
 19385         TBuf<CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength> itemStr;          
       
 19386         iStylusCcpuMenu = iUiInterface->NewStylusPopUpMenuL(this, aClickPoint);     
       
 19387         
       
 19388         if (items & KItemCopy)
       
 19389             {
       
 19390             StringLoader::Load(itemStr, R_AKNFEP_SOFTKEY_COPY);            
       
 19391             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditCopy);            
       
 19392             }
       
 19393         if (items & KItemCut)
       
 19394             {                    
       
 19395             itemStr.Zero();
       
 19396             StringLoader::Load(itemStr, R_AKNFEP_SOFTKEY_CUT);            
       
 19397             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditCut);
       
 19398             }
       
 19399         if (items & KItemPaste)
       
 19400             {
       
 19401             itemStr.Zero();
       
 19402             StringLoader::Load(itemStr, R_AKNFEP_STYLUS_CCPU_MENU_PASTE);               
       
 19403             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditPaste);                
       
 19404             }
       
 19405         
       
 19406         SetCcpuFlag(ECcpuStateCopy); // This forces ProcessCommandL to handle the events.
       
 19407         iStylusCcpuMenu->SetPosition(aClickPoint);    
       
 19408         iStylusCcpuMenu->ShowMenu();       
       
 19409         }
       
 19410     }
       
 19411 #endif    
       
 19412 
       
 19413 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19414  TBool CAknFepManager::IsFnKeyMappedL(TPtiKeyboardType aKeyboardType)
       
 19415     {
       
 19416     MPtiLanguage *lang = NULL;
       
 19417     RArray < TPtiNumericKeyBinding > keybinding;
       
 19418     TBool ret = EFalse;
       
 19419     if(iPtiEngine)
       
 19420         {
       
 19421         lang = iPtiEngine->CurrentLanguage();
       
 19422         if(lang)
       
 19423         {
       
 19424         iPtiEngine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, aKeyboardType);
       
 19425         TInt numericKeysCount = keybinding.Count();
       
 19426         while ( numericKeysCount-- )
       
 19427             {
       
 19428             TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount];
       
 19429             if ( numKeyBind.iCase == EPtiCaseFnLower || numKeyBind.iCase == EPtiCaseFnUpper)
       
 19430                 {
       
 19431                 ret = ETrue;
       
 19432                 break;
       
 19433                     }
       
 19434                 }
       
 19435             }
       
 19436         }
       
 19437     keybinding.Reset();
       
 19438     return ret;
       
 19439     }
       
 19440 TBool CAknFepManager::IsFnKeyMapped()
       
 19441     {
       
 19442     return iIsFnKeyMapped;
       
 19443     }
       
 19444     
       
 19445 void CAknFepManager::SetFnKeyMappingState()
       
 19446     {
       
 19447     TRAP_IGNORE(iIsFnKeyMapped = IsFnKeyMappedL());
       
 19448     }
       
 19449 
       
 19450 TBool CAknFepManager::KeyMapsDifferentCharacterWithFn( TPtiKey aKey ) const
       
 19451     {
       
 19452     // we are interested only about the first mapped character => buffer length 1 is adequate
       
 19453     TBuf<1> lowerMapping; 
       
 19454     TBuf<1> upperMapping;
       
 19455     TBuf<1> lowerFnMapping; 
       
 19456     TBuf<1> upperFnMapping;
       
 19457     iPtiEngine->MappingDataForKey( aKey, lowerMapping, EPtiCaseLower );
       
 19458     iPtiEngine->MappingDataForKey( aKey, upperMapping, EPtiCaseUpper );
       
 19459     iPtiEngine->MappingDataForKey( aKey, lowerFnMapping, EPtiCaseFnLower );
       
 19460     iPtiEngine->MappingDataForKey( aKey, upperFnMapping, EPtiCaseFnUpper );
       
 19461     
       
 19462     if ( lowerFnMapping.Length() )
       
 19463         {
       
 19464         if ( !lowerMapping.Length() ||              // < key maps character only with Fn
       
 19465              lowerMapping[0] != lowerFnMapping[0] ) // < Fn changes the character of the key
       
 19466             {
       
 19467             return ETrue;
       
 19468             }
       
 19469         }
       
 19470     else if ( upperFnMapping.Length() )
       
 19471         {
       
 19472         if ( !upperMapping.Length() ||              // < key maps character only with Fn
       
 19473              upperMapping[0] != upperFnMapping[0] ) // < Fn changes the character of the key
       
 19474             {
       
 19475             return ETrue;
       
 19476             }
       
 19477         }
       
 19478     
       
 19479     return EFalse; // The key doesn't have symbol behind Fn or the symbol is the same as without Fn
       
 19480     }
       
 19481 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19482 MAknFepDocumentNavigation* CAknFepManager::AknFepDocumentNavigation() const
       
 19483 	{
       
 19484 	MAknFepDocumentNavigation* navi = NULL;
       
 19485 	
       
 19486     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 19487     if ( mop )
       
 19488         {
       
 19489         mop->MopGetObject( navi );
       
 19490         }
       
 19491     
       
 19492     return navi;
       
 19493 	}
       
 19494 
       
 19495 CAknFepUIInterface* CAknFepManager::UiInterface()
       
 19496 	{
       
 19497 	return iUiInterface;
       
 19498 	}
       
 19499 
       
 19500 void CAknFepManager::AlignLogicalAndVisualCursorL()
       
 19501     {
       
 19502     TBool isIndicLang = 
       
 19503         TAknFepUiIndicInputManager::
       
 19504             IsIndicLangauge( TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
 19505 
       
 19506     if( isIndicLang )
       
 19507         {
       
 19508         TTmDocPosSpec pos = DocPos();
       
 19509         pos.iType = TTmDocPosSpec::ETrailing;
       
 19510         TTmPosInfo2 info;
       
 19511         TTmLineInfo lineInfo;
       
 19512 
       
 19513         TBool findAvailable = EFalse;
       
 19514 
       
 19515         MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 19516 
       
 19517         if ( docNavi )
       
 19518             {
       
 19519             docNavi->FindDocPos( pos, info, lineInfo );
       
 19520             findAvailable = ETrue;
       
 19521             }
       
 19522         else
       
 19523             {
       
 19524             CTextLayout* textLayout = TextLayout();
       
 19525             if ( textLayout )
       
 19526                 {
       
 19527                 textLayout->TagmaTextLayout().FindDocPos( pos, info, lineInfo );	    					    
       
 19528                 findAvailable = ETrue;
       
 19529                 }
       
 19530             }
       
 19531 
       
 19532         if ( findAvailable )
       
 19533             {
       
 19534             TCursorSelection sel( info.iDocPos.iPos, info.iDocPos.iPos );
       
 19535             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 19536             }
       
 19537         }
       
 19538     }
       
 19539 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19540 TKeyResponse CAknFepManager::HandleFnKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aEventCode )
       
 19541     {
       
 19542      TKeyResponse ret; 
       
 19543      
       
 19544 #ifdef __HALF_QWERTY_KEYPAD  
       
 19545      if ( IsFlagSet( EFlagShiftKeyDepressed ) && 
       
 19546         ( EPtiKeyboardHalfQwerty == KeyboardLayout() )&& 
       
 19547         ( aEventCode != EEventKeyUp ) )
       
 19548          {
       
 19549          return EKeyWasNotConsumed;
       
 19550          }
       
 19551 #endif
       
 19552      
       
 19553      if (!iCurrentFepUI->IsValidFnKeyPress() && EStdKeyRightFunc == aKeyEvent.iScanCode)
       
 19554      	{
       
 19555      	TBool Uiret = ETrue;
       
 19556      	if (EEventKeyDown == aEventCode )
       
 19557      		{
       
 19558       		Uiret = FepUI()->HandleKeyL(EKeyRightFunc, EShortKeyPress);     		
       
 19559      		}
       
 19560      		
       
 19561      	if (Uiret)
       
 19562      		{
       
 19563      		ret = EKeyWasConsumed;
       
 19564      		}
       
 19565         else
       
 19566         	{
       
 19567      	    ret = iFnKeyManager->HandleFnKeyEventL( aKeyEvent, aEventCode, 
       
 19568                                             	    iInputCapabilities ) ;     	        	
       
 19569         	}	 
       
 19570      	}
       
 19571      else
       
 19572      	{
       
 19573      	
       
 19574      	ret = iFnKeyManager->HandleFnKeyEventL( aKeyEvent, aEventCode, 
       
 19575                                             	iInputCapabilities ) ;     	
       
 19576      	}
       
 19577      if(IsHybridAplhaEditor() && !iHybridAplphaChangedToAlphanumeric)
       
 19578          {
       
 19579          if(FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
 19580             iHybridAplphaChangedToAlphanumeric = ETrue;
       
 19581          }
       
 19582 
       
 19583      return ret;
       
 19584     }
       
 19585 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19586 
       
 19587 // -----------------------------------------------------------------------------
       
 19588 // CAknFepManager::HasJapanesePredictionInputMode
       
 19589 // Has Japanese prediction input mode in PtiEngine
       
 19590 // -----------------------------------------------------------------------------
       
 19591 //
       
 19592 TBool CAknFepManager::HasJapanesePredictionInputMode() const
       
 19593     {
       
 19594     // Is it supported Japanese predictive input
       
 19595     TBool ret = EFalse;
       
 19596     MPtiLanguage* ptilang = iPtiEngine->GetLanguage(ELangJapanese);
       
 19597     if ( ptilang
       
 19598      &&  ( (!iQwertyInputMode && ptilang->HasInputMode(EPtiEngineHiraganaKanjiPredictive))
       
 19599          ||(iQwertyInputMode && ptilang->HasInputMode(EPtiEngineHiraganaKanjiPredictiveQwerty)) ) )
       
 19600         {
       
 19601         ret = ETrue;
       
 19602         }
       
 19603     return ret;
       
 19604     }
       
 19605 #ifdef RD_HINDI_PHONETIC_INPUT
       
 19606 void CAknFepManager::HandleIndicCaseL()
       
 19607 	{
       
 19608 		iHashKeyMan->HandleSetIndicStateL();
       
 19609 	}
       
 19610 #endif
       
 19611 
       
 19612 // -----------------------------------------------------------------------------
       
 19613 // CAknFepManager::IsCursorAtEndOfWord
       
 19614 // 
       
 19615 // -----------------------------------------------------------------------------
       
 19616 //    
       
 19617 TBool CAknFepManager::IsCursorAtEndOfWord()
       
 19618     {   
       
 19619     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 19620     TInt origPos = iUncommittedText.iCursorPos; 
       
 19621    
       
 19622     FindEndOfWord(iUncommittedText.iCursorPos);
       
 19623        
       
 19624     if (origPos != iUncommittedText.iCursorPos)
       
 19625         {
       
 19626         return EFalse;
       
 19627         }
       
 19628         
       
 19629     return ETrue;        
       
 19630     }
       
 19631 
       
 19632 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19633 TInt CAknFepManager::GetCurrentCase()
       
 19634     {
       
 19635     TCase returnCase;
       
 19636     
       
 19637     switch( iCaseMan->CurrentCase() )
       
 19638         {
       
 19639         case EAknEditorUpperCase:
       
 19640         case EAknEditorTextCase:
       
 19641             {
       
 19642             returnCase = EUpperCase;
       
 19643             }
       
 19644             break;
       
 19645 
       
 19646         case EAknEditorLowerCase:
       
 19647             {
       
 19648             returnCase = ELowerCase;
       
 19649             }
       
 19650             break;
       
 19651         
       
 19652         default:
       
 19653             returnCase = ELowerCase;
       
 19654             break;
       
 19655         }
       
 19656     return returnCase;
       
 19657     }
       
 19658 // Predictive QWERTY changes (XT9) ---->
       
 19659 
       
 19660 void CAknFepManager::GetCandidatesL( CDesCArray& aArray, TInt& aActiveIdx )
       
 19661     {
       
 19662     iPtiEngine->GetCandidateListL(aArray);
       
 19663     iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &aActiveIdx );
       
 19664     }  
       
 19665 
       
 19666 void CAknFepManager::GetUpdateCandidatePositionL(TRect& aRect)
       
 19667     {
       
 19668      if(iCandidatePopup && iFepFullyConstructed && iPtiEngine)
       
 19669         {
       
 19670         //Now we read the position of the inline text
       
 19671         TPoint  inlineEditorTl;
       
 19672         TPoint  inlineEditorBr;
       
 19673         TInt    height;
       
 19674         TInt    ascent;
       
 19675         TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
 19676         //  Popup Position for RTL
       
 19677         if(iLanguageCapabilities.iRightToLeftLanguage)
       
 19678             documentOffset = 0;
       
 19679         //  Popup Position for RTL
       
 19680         GetScreenCoordinatesL(inlineEditorTl, height, ascent, documentOffset);
       
 19681         inlineEditorTl.iY -= height;
       
 19682         GetScreenCoordinatesL(inlineEditorBr, height, ascent);
       
 19683         aRect.iTl = inlineEditorTl;
       
 19684         aRect.iBr = inlineEditorBr;
       
 19685         }
       
 19686     }
       
 19687 
       
 19688 TBool CAknFepManager::IsRightToLeftLanguage()
       
 19689 	{
       
 19690 	return iLanguageCapabilities.iRightToLeftLanguage ;
       
 19691 	}
       
 19692 
       
 19693 /**
       
 19694 * Setter for the advanced predictive typing correction.
       
 19695 * @param    aLevel   The level to be set.
       
 19696 */
       
 19697 void CAknFepManager::SetTypingCorrectionLevel(TInt aLevel)
       
 19698 	{
       
 19699 	iTypingCorrectionLevel = aLevel;
       
 19700     
       
 19701 	if(iFepFullyConstructed)
       
 19702 		{
       
 19703 		TPtiErrorCorrectionLevel correctionLevel = (TPtiErrorCorrectionLevel)aLevel;
       
 19704 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetCorrectionLevel, &correctionLevel ));	
       
 19705 		}
       
 19706 	}
       
 19707 	
       
 19708 /**
       
 19709 * Resetter for the advanced predictive Number Candidate setting.
       
 19710 * @param    aValue   The value to be set.
       
 19711 */
       
 19712 void CAknFepManager::SetNumberCandidateState(TInt aValue)
       
 19713 	{
       
 19714 	if(aValue == 0)
       
 19715 		iIsNumberCandidateShown = EFalse;
       
 19716 	else if(aValue == 1)
       
 19717 		iIsNumberCandidateShown = ETrue;
       
 19718 	
       
 19719 	if(iFepFullyConstructed)
       
 19720 		{
       
 19721 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, 
       
 19722 		                                        &iIsNumberCandidateShown ));
       
 19723 		}
       
 19724 	}
       
 19725 	
       
 19726 void CAknFepManager::RemoveSuggestedAdvanceCompletionL()
       
 19727     {	
       
 19728     if( IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) &&
       
 19729         iPtiEngine->CurrentWord().Length() )
       
 19730         {
       
 19731         TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandUserActionShorten ));
       
 19732         TPtrC currentText = iPtiEngine->CurrentWord();
       
 19733         UpdateInlineEditL( currentText, currentText.Length() );
       
 19734         }
       
 19735     }
       
 19736 /**
       
 19737 * Setes the current state from GS to the local state
       
 19738 */    
       
 19739    
       
 19740 void CAknFepManager::SetAutoCompletionState(TInt aValue) 
       
 19741 	{
       
 19742 	if(aValue == 0)
       
 19743 		{
       
 19744 		iIsAutoCompleteOn = EFalse;
       
 19745 		}
       
 19746 	else if(aValue == 1)
       
 19747 		{
       
 19748 		iIsAutoCompleteOn = ETrue;
       
 19749 		}
       
 19750 	 
       
 19751 	if(iFepFullyConstructed)
       
 19752 		{
       
 19753 		if(iIsAutoCompleteOn)
       
 19754 			{
       
 19755 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandEnableAutoCompletion  ));
       
 19756 			}
       
 19757 		else
       
 19758 			{
       
 19759 			TInt tailLength = 0;
       
 19760 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 19761 			if(tailLength > 0)
       
 19762 				{
       
 19763 				// send an update to engine to signify change in autocompletion from on to off while tail exists
       
 19764 				// This will set EPtiXt9FlagAutoCompletionSetOnToOff flag as true in engine
       
 19765 				TInt value = 1;
       
 19766 				TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandAutoCompletionOnToOff,&value));				
       
 19767 				}
       
 19768 			
       
 19769 			
       
 19770 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandDisableAutoCompletion ));
       
 19771 			}
       
 19772 		}
       
 19773 	}
       
 19774 	
       
 19775 /**
       
 19776 * Sets the primary candidate from GS to the local state
       
 19777 */    
       
 19778    
       
 19779 void CAknFepManager::SetPrimaryCandidate(TInt aValue) 
       
 19780 	{
       
 19781 	if(aValue == 0)
       
 19782 		iPrimaryCandidate = ETrue;
       
 19783 	else if(aValue == 1)
       
 19784 		iPrimaryCandidate = EFalse;    
       
 19785 	if(iFepFullyConstructed)
       
 19786 		{
       
 19787 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetProactiveCorrection, 
       
 19788 		                                        &iPrimaryCandidate ));
       
 19789 		}
       
 19790 	}
       
 19791 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19792     
       
 19793 CAknFepPluginManager* CAknFepManager::PluginUIManager()
       
 19794     {
       
 19795 #ifdef RD_SCALABLE_UI_V2
       
 19796 
       
 19797     return iFepPluginManager;
       
 19798 #else
       
 19799     return NULL;        
       
 19800 #endif //RD_SCALABLE_UI_V2     
       
 19801     }
       
 19802 
       
 19803 // add for phrase creation
       
 19804 MZhuyinKeyHandler* CAknFepManager::ZhuyinKeyHandler()
       
 19805     {
       
 19806     return iZhuyinKeyHandler;
       
 19807     }
       
 19808 // add for phrase creation
       
 19809 CAknFepZhuyinAnalyser* CAknFepManager::ZhuyinAnalyser()
       
 19810     {
       
 19811     return iZhuyinAnalyser;
       
 19812     }
       
 19813 
       
 19814 #ifdef RD_SCALABLE_UI_V2
       
 19815 void CAknFepManager::UpdateTouchCaseMode()
       
 19816 	{
       
 19817     if (iFepFullyConstructed && 
       
 19818         iFepPluginManager 
       
 19819         // case should be updated even if current input mode is none because iPreviousCoseMode
       
 19820         // still need to be updated.
       
 19821         /*&& 
       
 19822         iFepPluginManager->PluginInputMode() != EPluginInputModeNone*/)
       
 19823     	{
       
 19824     	iFepPluginManager->UpdateCaseMode();	
       
 19825     	}
       
 19826 	}
       
 19827 #endif// RD_SCALABLE_UI_V2
       
 19828 
       
 19829 void CAknFepManager::SetStopProcessFocus(TBool aStop, TBool aClose)
       
 19830     {
       
 19831     iClosePeninputUi = aClose;
       
 19832     iStopProcessFocus = aStop;
       
 19833     if (!aStop)
       
 19834         {
       
 19835         HandleChangeInFocus();
       
 19836         }
       
 19837     }
       
 19838     
       
 19839 TBool CAknFepManager::StopProcessFocus()
       
 19840     {
       
 19841     return iStopProcessFocus;    
       
 19842     }
       
 19843     
       
 19844 TBool CAknFepManager::CloseUiOnFocusChange()
       
 19845     {
       
 19846     return iClosePeninputUi;    
       
 19847     }
       
 19848 void CAknFepManager::HandleCopyCutStateL()    
       
 19849 {
       
 19850     if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
 19851                 {
       
 19852                 TCursorSelection selection;
       
 19853                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 19854                 TBool update;
       
 19855                 if (selection.Length() > 0)
       
 19856                     {
       
 19857                     if (!IsCcpuFlagSet(ECcpuStateButton))
       
 19858                         {
       
 19859                         __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
 19860                                        AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));                         
       
 19861                         if (IsCcpuFlagSet(ECcpuStateCopy))                      
       
 19862                             {
       
 19863                             update = UpdateCBALabelL(ELeftSoftkeyIndex, EEikCmdEditCopy, R_AKNFEP_SOFTKEY_COPY);
       
 19864                             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EEikCmdEditCopy, R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
 19865                             }
       
 19866                         else
       
 19867                             {
       
 19868                             update = UpdateCBALabelL(ELeftSoftkeyIndex, EEikCmdEditCut, R_AKNFEP_SOFTKEY_CUT);                          
       
 19869                             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EEikCmdEditCut, R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
 19870                             }
       
 19871                         if (update)
       
 19872                             {
       
 19873                             iUiInterface->DrawSoftkeysNow();
       
 19874                             }               
       
 19875                         SetCcpuFlag(ECcpuStateButton);                                      
       
 19876                         }                   
       
 19877                     }   
       
 19878                 else if (IsCcpuFlagSet(ECcpuStateButton))                        
       
 19879                     {                   
       
 19880                     ClearCcpuFlag(ECcpuStateButton);
       
 19881                     update = EFalse;
       
 19882                     update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
 19883                     update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY );
       
 19884                     if (update)
       
 19885                         {
       
 19886                         iUiInterface->DrawSoftkeysNow();
       
 19887                         }               
       
 19888                     }
       
 19889                 }    
       
 19890 }    
       
 19891 #ifdef RD_SCALABLE_UI_V2
       
 19892 TInt GetForegroundTaskAppWgId()
       
 19893     {
       
 19894     TApaTaskList tList(CCoeEnv::Static()->WsSession());
       
 19895     
       
 19896     TApaTask task = tList.FindByPos(0);
       
 19897     return task.WgId();
       
 19898     }
       
 19899 
       
 19900 void CAknFepManager::DimInputmodeTouchMenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 19901     {
       
 19902     DimEditMenuModeItems(aMenuPane);
       
 19903 
       
 19904     if ( IsChineseInputLanguage() )
       
 19905         {
       
 19906         DoChineseTouchMenu(aMenuPane);
       
 19907         }
       
 19908     else if ( iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 19909         {
       
 19910         DoJapaneseMenu(aMenuPane);
       
 19911         }
       
 19912     else
       
 19913         {
       
 19914         DoWesternTouchMenu(aMenuPane);
       
 19915         }
       
 19916     }
       
 19917 #endif
       
 19918 
       
 19919 void CAknFepManager::DimInputmodeMenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 19920     {
       
 19921     DimEditMenuModeItems(aMenuPane);
       
 19922 
       
 19923     if ( IsChineseInputLanguage() )
       
 19924         {
       
 19925         DoChineseMenu(aMenuPane);
       
 19926         }
       
 19927     else if ( iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 19928         {
       
 19929         DoJapaneseMenu(aMenuPane);
       
 19930         }
       
 19931     else
       
 19932         {
       
 19933         DoWesternMenu(aMenuPane);
       
 19934         }
       
 19935     }
       
 19936 
       
 19937 void CAknFepManager::HandleCopyCutEventL(TInt aCommandId)
       
 19938     {
       
 19939      if (iCcpuMode != ECcpuStateNone)
       
 19940         {                   
       
 19941         ResetCcpuFlags();                   
       
 19942         iUiInterface->DeleteSoftkeys();
       
 19943                     
       
 19944         SetCcpuFlag(ECcpuStatePosted);  
       
 19945                                          
       
 19946 #ifdef RD_SCALABLE_UI_V2                    
       
 19947         if (aCommandId == EEikCmdEditCopy)
       
 19948             {                     
       
 19949             // Send copy event to AknCcpuSupport.
       
 19950             CCoeEnv::Static()->SimulateKeyEventL(KAknCcpuCopyEvent, EEventKey);
       
 19951             }
       
 19952         else
       
 19953             {
       
 19954             // Send cut event to AknCcpuSupport.
       
 19955             CCoeEnv::Static()->SimulateKeyEventL(KAknCcpuCutEvent, EEventKey);
       
 19956             }                               
       
 19957 #else         
       
 19958 /*As part of build warnings commenting this perticular code it might require when touch is enabled.        
       
 19959         if (aCommandId == EEikCmdEditCopy)
       
 19960             {                                          
       
 19961             // Send copy-event to editor.
       
 19962             CCoeEnv::Static()->SimulateKeyEventL(KEditorCopyEvent, EEventKey);
       
 19963             }
       
 19964         else 
       
 19965             {                       
       
 19966             // send cut-event to editor.         
       
 19967             CCoeEnv::Static()->SimulateKeyEventL(KEditorCutEvent, EEventKey);
       
 19968             } 
       
 19969 			*/            
       
 19970 #endif // RD_SCALABLE_UI_V2 
       
 19971 
       
 19972         if (iInputCapabilities.FepAwareTextEditor())                                
       
 19973             {
       
 19974             // update indicators only if this is editable component.
       
 19975             iIndicator->SetCopyMode(EFalse);
       
 19976             UpdateIndicators();                                                           
       
 19977             }
       
 19978 #ifdef  RD_SCALABLE_UI_V2       	 
       
 19979         HandleChangeInFocus();
       
 19980 #endif
       
 19981         
       
 19982         }
       
 19983 
       
 19984     }
       
 19985 
       
 19986 TInt CAknFepManager::FepShowVkbPreviewStatus()
       
 19987     {
       
 19988     return iSharedDataInterface->FepShowVkbPreviewStatus();    
       
 19989     }
       
 19990 
       
 19991 void CAknFepManager::InitPreviewMenuPane(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 19992     {
       
 19993     if (FepShowVkbPreviewStatus() > 0)
       
 19994         {
       
 19995         aMenuPane->GetMenuPane()->SetItemButtonState(EPenInputCmdPreviewOn, 
       
 19996                                                      EEikMenuItemSymbolOn );
       
 19997         }
       
 19998     else
       
 19999         {
       
 20000         aMenuPane->GetMenuPane()->SetItemButtonState(EPenInputCmdPreviewOff, 
       
 20001                                                      EEikMenuItemSymbolOn );
       
 20002         }
       
 20003     }
       
 20004 
       
 20005 void CAknFepManager::SynCCPSoftKey()
       
 20006     {
       
 20007     TRAP_IGNORE(HandleCopyCutStateL());   
       
 20008     }
       
 20009 
       
 20010 TInt CAknFepManager::PluginInputMode() const
       
 20011 {
       
 20012 #ifdef RD_SCALABLE_UI_V2
       
 20013     return iFepPluginManager ? iFepPluginManager->PluginInputMode() : EPluginInputModeNone;
       
 20014 #else
       
 20015     return EPluginInputModeNone;
       
 20016 #endif 
       
 20017 }
       
 20018 
       
 20019 void CAknFepManager::HandleEndKeyL()
       
 20020     {
       
 20021 #ifdef RD_SCALABLE_UI_V2 
       
 20022 
       
 20023     if (iFepPluginManager)
       
 20024         {
       
 20025         return;    
       
 20026         }
       
 20027 
       
 20028     RWsSession &ws = CCoeEnv::Static()->WsSession();
       
 20029     //TInt wgId =ws.GetFocusWindowGroup();
       
 20030     CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(ws,
       
 20031         CCoeEnv::Static()->WsSession().GetFocusWindowGroup());
       
 20032 
       
 20033     TUid id = wg->AppUid();
       
 20034     CleanupStack::PopAndDestroy(wg); 
       
 20035 
       
 20036     if (0x10207218 == id.iUid ||
       
 20037         0x10281EF2 == id.iUid)
       
 20038         {
       
 20039         RPeninputServer iPenInputServer;
       
 20040 
       
 20041         TInt err = iPenInputServer.Connect();
       
 20042 		if(err == KErrNone)
       
 20043 			{
       
 20044 			iPenInputServer.SetForeground(ETrue);
       
 20045 			iPenInputServer.ActivateLayout( EFalse ); 
       
 20046 			iPenInputServer.HandleCommand(ECmdPenInputWindowClose);
       
 20047 			
       
 20048 			iPenInputServer.ClearServerEvent();
       
 20049 			iPenInputServer.LoseForeground();
       
 20050 			iPenInputServer.Close();
       
 20051 			}
       
 20052         }
       
 20053 #endif //RD_SCALABLE_UI_V2         
       
 20054     }
       
 20055 void CAknFepManager::NeedDisableKeySound(const TKeyEvent& aKeyEvent, TEventCode aEventCode)
       
 20056     {
       
 20057 #ifdef RD_SCALABLE_UI_V2    
       
 20058     TInt keyCode = aKeyEvent.iScanCode;
       
 20059     TBool interestKey = EFalse;
       
 20060     if ( keyCode == EPtiKey0 || 
       
 20061          keyCode == EPtiKey1 ||
       
 20062          keyCode == EPtiKey2 ||
       
 20063          keyCode == EPtiKey3 ||
       
 20064          keyCode == EPtiKey4 ||
       
 20065          keyCode == EPtiKey5 ||
       
 20066          keyCode == EPtiKey6 ||
       
 20067          keyCode == EPtiKey7 ||
       
 20068          keyCode == EPtiKey8 ||
       
 20069          keyCode == EPtiKey9 ||
       
 20070          keyCode == EStdKeyDownArrow ||
       
 20071          keyCode == EStdKeyRightArrow ||
       
 20072          keyCode == EStdKeyLeftArrow ||
       
 20073          keyCode == EStdKeyUpArrow ||
       
 20074          keyCode == EStdKeyBackspace
       
 20075          )
       
 20076         {
       
 20077         interestKey = ETrue;
       
 20078         }
       
 20079     if( interestKey && iFepPluginManager && 
       
 20080         iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
 20081         {
       
 20082         if( aEventCode == EEventKeyDown )
       
 20083             {
       
 20084             static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->
       
 20085                  DisableNextKeySound( keyCode ); 
       
 20086             }
       
 20087         else if( aEventCode == EEventKey )
       
 20088             {
       
 20089 			#ifdef RD_TACTILE_FEEDBACK
       
 20090             MTouchFeedback::Instance()->
       
 20091                 InstantFeedback(ETouchFeedbackSensitive);
       
 20092 			#endif
       
 20093             }
       
 20094         }
       
 20095 #endif     
       
 20096     }
       
 20097 
       
 20098 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 20099 void CAknFepManager::SetComposChrFlag( TBool aFlag )
       
 20100     {
       
 20101     iComposChrFlag = aFlag;
       
 20102     }
       
 20103 TBool CAknFepManager::GetComposChrFlag( )
       
 20104     {
       
 20105     return iComposChrFlag;
       
 20106     }
       
 20107 #endif
       
 20108 
       
 20109 // add for phrase creation User db view
       
 20110 void CAknFepManager::AddUserDBDlgItemL( CAknFepUiInterfaceMenuPane* aMenuPane, TInt aIndex )
       
 20111     {
       
 20112     CAknFepUiInterfaceMenuPane::SItemData mData;
       
 20113 
       
 20114     TBuf<KMaxFileName> langStr;
       
 20115     TInt Inputlangindex;
       
 20116     if (!aMenuPane->MenuItemExists(EAknCmdUserDBDlg, Inputlangindex))
       
 20117         {
       
 20118         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_USER_DB_DLG);
       
 20119 
       
 20120         mData.iCommandId = EAknCmdUserDBDlg;
       
 20121         mData.iCascadeId = 0;
       
 20122         mData.iFlags = 0;
       
 20123         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
 20124 
       
 20125         aMenuPane->InsertMenuItemL(mData, aIndex);
       
 20126         }
       
 20127     }
       
 20128 // add for phrase creation
       
 20129 void CAknFepManager::LaunchUserDBDlgL( )
       
 20130     {
       
 20131     TInt itemIndex = 0;
       
 20132     
       
 20133     //Change title text
       
 20134     CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
 20135     CAknTitlePane* title = static_cast< CAknTitlePane* >(
       
 20136         statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle) ) );
       
 20137 
       
 20138     //Save the old title tet
       
 20139     HBufC* Oldtitletext = title->Text()->AllocLC();
       
 20140     //Load the new title text
       
 20141     HBufC* titletext = StringLoader::LoadLC( R_AKNFEP_USER_DB_MANAGEMENT_TITLE );
       
 20142     //Set title to the new text
       
 20143     title->SetTextL( *titletext );
       
 20144 
       
 20145     CDesCArray* items = new( ELeave ) CDesCArrayFlat( KSelectItemSize );
       
 20146     CleanupStack::PushL( items );
       
 20147     CArrayFix<TInt>* selectedItems = new( ELeave ) CArrayFixFlat<TInt>( KSelectItemSize );
       
 20148     CleanupStack::PushL( selectedItems );
       
 20149     
       
 20150     CAknToolbar* toolbar = iAvkonAppUi->CurrentFixedToolbar();
       
 20151     
       
 20152     if( toolbar && toolbar->IsShown() && toolbar->CountComponentControls()>0 )
       
 20153         {
       
 20154         toolbar->SetDimmed( ETrue );
       
 20155         toolbar->DrawDeferred();
       
 20156         }
       
 20157     
       
 20158     TUid naviPaneUid;
       
 20159 	naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
 20160 
       
 20161 	CEikStatusPaneBase::TPaneCapabilities subPane =
       
 20162 			statusPane->PaneCapabilities(naviPaneUid);
       
 20163 	// if we can access the navigation pane
       
 20164 	if (subPane.IsPresent() && subPane.IsAppOwned())
       
 20165 		{
       
 20166 		CAknNavigationControlContainer
       
 20167 				* naviPane =
       
 20168 						(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
       
 20169 		iTapGroup = naviPane->CreateTabGroupL();
       
 20170 		iTapGroup->MakeVisible( EFalse );
       
 20171 		naviPane->PushL( *iTapGroup );
       
 20172 		}
       
 20173     
       
 20174     iUserdbdlg = CAknFepUserdbDlg::NewL( itemIndex,
       
 20175         selectedItems, items, R_AKNFEP_USERDB_DLG_MENUBAR, iPtiEngine, this );
       
 20176     
       
 20177     iIsUserdbdlgActive = 1;
       
 20178     
       
 20179     iUserdbdlg->RunLD();
       
 20180     
       
 20181     iIsUserdbdlgActive = 0;
       
 20182     
       
 20183 	// if we can access the navigation pane
       
 20184 	if (subPane.IsPresent() && subPane.IsAppOwned())
       
 20185 		{
       
 20186 
       
 20187 		CAknNavigationControlContainer
       
 20188 				* naviPane =
       
 20189 						(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
       
 20190 		naviPane->Pop();
       
 20191 		delete iTapGroup;
       
 20192 		iTapGroup = NULL;
       
 20193 		}
       
 20194 	
       
 20195     //Set the title to old text
       
 20196     title->SetTextL( *Oldtitletext );
       
 20197     
       
 20198     if( toolbar )
       
 20199         {
       
 20200         toolbar->SetDimmed( EFalse );
       
 20201         toolbar->DrawNow();
       
 20202         }
       
 20203     
       
 20204     CleanupStack::PopAndDestroy( selectedItems );
       
 20205     CleanupStack::PopAndDestroy( items );
       
 20206     CleanupStack::PopAndDestroy( titletext );
       
 20207     CleanupStack::PopAndDestroy( Oldtitletext );
       
 20208     iUserdbdlg = NULL;
       
 20209     }
       
 20210 // add for phrase creation
       
 20211 TBool CAknFepManager::IsPinyinPhraseCreation() const
       
 20212     {
       
 20213     return iPinyinPhraseCreation;
       
 20214     }
       
 20215 
       
 20216 void CAknFepManager::PinyinPhraseCreation(  TBool aPinyinPhraseCreation )
       
 20217     {
       
 20218     if ( iPinyinPhraseCreation != aPinyinPhraseCreation )
       
 20219         {
       
 20220         iPinyinPhraseCreation = aPinyinPhraseCreation;
       
 20221         }
       
 20222     }
       
 20223 // add for phrase creation
       
 20224 TBool CAknFepManager::IsPhraseCreation() const
       
 20225     {
       
 20226     return iPhraseCreation;
       
 20227     }
       
 20228 // add for phrase creation
       
 20229 void CAknFepManager::PhraseCreation(  TBool aPhraseCreation )
       
 20230     {
       
 20231     if ( iPhraseCreation != aPhraseCreation )
       
 20232         {
       
 20233         iPhraseCreation = aPhraseCreation;
       
 20234         }
       
 20235     }
       
 20236 // add for phrase creation
       
 20237 TBool CAknFepManager::IsEntryPhrase() const
       
 20238     {
       
 20239     return iEntryPhrase;
       
 20240     }
       
 20241 // add for phrase creation
       
 20242 void CAknFepManager::EntryPhrase( TBool aEntryPhrase )
       
 20243     {
       
 20244     if ( iEntryPhrase != aEntryPhrase )
       
 20245         {
       
 20246         iEntryPhrase = aEntryPhrase;
       
 20247         }
       
 20248     }
       
 20249 // add for phrase creation
       
 20250 void CAknFepManager::EnableKeyStar( TBool aEnable )
       
 20251     {
       
 20252     if ( iKeyStar != aEnable )
       
 20253         {
       
 20254         iKeyStar = aEnable;
       
 20255         }
       
 20256     }
       
 20257 // add for phrase creation
       
 20258 TBool CAknFepManager::IsEnableKeyStar( ) const
       
 20259     {
       
 20260     return iKeyStar;
       
 20261     }
       
 20262 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 20263 	
       
 20264 
       
 20265 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 20266 /**
       
 20267 * @return   ETrue   If the number entry with long key press is supported on QWERTY keyboard.
       
 20268 */
       
 20269 TBool CAknFepManager::LongPressNumberEntryOnQwerty() const
       
 20270     {
       
 20271     TBool value = EFalse;
       
 20272     if ( iSharedDataInterface )
       
 20273         {
       
 20274         value = iSharedDataInterface->LongPressNumberEntryOnQwerty();
       
 20275         }
       
 20276     return value;
       
 20277     }
       
 20278 
       
 20279 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 20280 
       
 20281 
       
 20282 void CAknFepManager::MultitapThroughSCTCharL(TCallBack aCallBack)
       
 20283     {
       
 20284     
       
 20285 	TInt res = GetNumericSCTResID();
       
 20286     
       
 20287     if(!res)
       
 20288     	{
       
 20289     	return;
       
 20290     	}
       
 20291 
       
 20292     if(!iNumericResourceTimer)
       
 20293         {        
       
 20294         iNumericResourceTimer = CChrMultiTapTimer::NewL(aCallBack);
       
 20295         }
       
 20296     
       
 20297     if(!iResourceString || iNumericResourceId !=res )
       
 20298         {
       
 20299         // either the resource string has not be created or the resource ID has changed
       
 20300         if(iResourceString)
       
 20301             {
       
 20302             delete iResourceString;
       
 20303             iResourceString = NULL;
       
 20304             }
       
 20305         iNumericResourceId = res;
       
 20306         TResourceReader reader;
       
 20307         CEikonEnv::Static()->CreateResourceReaderLC(reader,iNumericResourceId);
       
 20308         reader.ReadInt32(); // skip sct id 
       
 20309         iResourceString = reader.ReadHBufC16L();
       
 20310         CleanupStack::PopAndDestroy();
       
 20311         }
       
 20312     if(!iResourceString)
       
 20313         {
       
 20314         return;
       
 20315         }
       
 20316     if(iNumericResourceTimer->IsActive())
       
 20317         {
       
 20318         if( iChrCharIndex == iResourceString->Length() )
       
 20319             {
       
 20320             iChrCharIndex = 0;            
       
 20321             }
       
 20322     
       
 20323         iNumericResourceTimer->Cancel();
       
 20324         iNumericResourceTimer->After(KChrKeyMultitapTimeout);        
       
 20325         }
       
 20326     else
       
 20327         {
       
 20328         iChrCharIndex = 0;
       
 20329         iNumericResourceTimer->After(KChrKeyMultitapTimeout);
       
 20330         }    
       
 20331     TBuf<1> buf;
       
 20332     buf.Append((*iResourceString)[iChrCharIndex]); 
       
 20333     NewCharacterL(buf);
       
 20334     iChrCharIndex++;
       
 20335     	if (iResourceString->Length() == 1)
       
 20336 		{
       
 20337 		NumericResourceMultiTapTimerTimeoutL();
       
 20338 		}
       
 20339 
       
 20340     }
       
 20341 TBool CAknFepManager::NumericResourceMultiTapTimerTimeoutL()
       
 20342     {
       
 20343     if(iNumericResourceTimer->IsActive())
       
 20344     	{
       
 20345     	iNumericResourceTimer->Cancel();
       
 20346     	if(IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
 20347 	        {
       
 20348 	        CommitInlineEditL();
       
 20349 	        return ETrue;
       
 20350 	        } 
       
 20351     	}       
       
 20352     return EFalse;    
       
 20353     }    
       
 20354     
       
 20355 //-------------------------------------------------------------------
       
 20356 
       
 20357 //
       
 20358 // CChrMultiTapTimer
       
 20359 //
       
 20360 
       
 20361 // ---------------------------------------------------------------------------
       
 20362 // CChrMultiTapTimer::NewL
       
 20363 // 
       
 20364 // ---------------------------------------------------------------------------
       
 20365 // 
       
 20366 CChrMultiTapTimer* CChrMultiTapTimer::NewL(TCallBack aCallback)
       
 20367     {
       
 20368     CChrMultiTapTimer* self = new(ELeave)CChrMultiTapTimer(aCallback);
       
 20369     CleanupStack::PushL(self);
       
 20370     self->ConstructL();
       
 20371     CleanupStack::Pop();    // self
       
 20372     return self;
       
 20373     }
       
 20374 
       
 20375 
       
 20376 // ---------------------------------------------------------------------------
       
 20377 // CChrMultiTapTimer::CChrMultiTapTimer
       
 20378 // 
       
 20379 // ---------------------------------------------------------------------------
       
 20380 // 
       
 20381 CChrMultiTapTimer::CChrMultiTapTimer(TCallBack aCallback)
       
 20382 :CTimer(EPriorityStandard), iCallback(aCallback)
       
 20383     {
       
 20384     }
       
 20385 
       
 20386 // ---------------------------------------------------------------------------
       
 20387 // CChrMultiTapTimer::ConstructL
       
 20388 // 
       
 20389 // ---------------------------------------------------------------------------
       
 20390 // 
       
 20391 void CChrMultiTapTimer::ConstructL()
       
 20392     {
       
 20393     CTimer::ConstructL();
       
 20394     CActiveScheduler::Add(this);
       
 20395     }
       
 20396 
       
 20397 // ---------------------------------------------------------------------------
       
 20398 // CChrMultiTapTimer::After
       
 20399 // 
       
 20400 // ---------------------------------------------------------------------------
       
 20401 // 
       
 20402 void CChrMultiTapTimer::After(TTimeIntervalMicroSeconds32 aInterval)
       
 20403     {
       
 20404     if (IsActive())
       
 20405         {
       
 20406         Cancel();
       
 20407         }
       
 20408     CTimer::After(aInterval);
       
 20409     }
       
 20410 
       
 20411 // ---------------------------------------------------------------------------
       
 20412 // CChrMultiTapTimer::RunL
       
 20413 // 
       
 20414 // ---------------------------------------------------------------------------
       
 20415 // 
       
 20416 void CChrMultiTapTimer::RunL()
       
 20417     {
       
 20418     iCallback.CallBack();
       
 20419     }
       
 20420 
       
 20421 TBool CAknFepManager::IsLanguageSupportPrediction()
       
 20422     {
       
 20423     TBool isLanguagugeSupportsPrediction = EFalse;
       
 20424     switch(iKeyboardType)
       
 20425         {
       
 20426         case EPtiKeyboardHalfQwerty:
       
 20427 #ifdef __HALF_QWERTY_KEYPAD
       
 20428             isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive); 
       
 20429 #endif              
       
 20430             break;
       
 20431         case EPtiKeyboardQwerty4x12:
       
 20432         case EPtiKeyboardQwerty4x10:
       
 20433         case EPtiKeyboardQwerty3x11:
       
 20434         case EPtiKeyboardCustomQwerty:
       
 20435             isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternQwertyPredictive);
       
 20436             break;
       
 20437         case EPtiKeyboardNone:
       
 20438         case EPtiKeyboard12Key:
       
 20439             isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
 20440             break;
       
 20441         default:
       
 20442             isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
 20443             break;    
       
 20444         }    
       
 20445     return isLanguagugeSupportsPrediction;
       
 20446     }
       
 20447 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 20448 
       
 20449 TBool CAknFepManager::IsAllowedKeymappingForNumberMode(TChar aChar) const
       
 20450     {
       
 20451     TBool response = EFalse;
       
 20452 
       
 20453 
       
 20454     switch ( iAknEditorNumericKeymap )
       
 20455         {
       
 20456         case EAknEditorStandardNumberModeKeymap:
       
 20457         case EAknEditorFixedDiallingNumberModeKeymap:
       
 20458         case EAknEditorSATNumberModeKeymap:
       
 20459         case EAknEditorSATHiddenNumberModeKeymap:
       
 20460             {
       
 20461             response = (aChar == '#');
       
 20462             }
       
 20463             break;
       
 20464         case EAknEditorCalculatorNumberModeKeymap:
       
 20465         case EAknEditorConverterNumberModeKeymap:
       
 20466             {
       
 20467             TLocale tLoc;
       
 20468             response = (aChar == tLoc.DecimalSeparator());
       
 20469             }
       
 20470             break;
       
 20471         case EAknEditorToFieldNumberModeKeymap:
       
 20472             {
       
 20473             response = (aChar == ';');
       
 20474             }
       
 20475             break;
       
 20476         case EAknEditorPlainNumberModeKeymap:
       
 20477         case EAknEditorReservedInternalUseKeymap:
       
 20478         default:
       
 20479             break;
       
 20480         }
       
 20481 
       
 20482     return response;
       
 20483     }
       
 20484 /**
       
 20485   * Return wether ipnut mode is change by press shift+space. 
       
 20486   * This is for half-qwerty.
       
 20487   */
       
 20488 TBool CAknFepManager::IsChangeModeByShiftAndSpace()
       
 20489     {
       
 20490     return iShiftAndSpace;
       
 20491     }
       
 20492 
       
 20493 /**
       
 20494   * Set wether ipnut mode is change by press shift+space. 
       
 20495   * This is for half-qwerty.
       
 20496   */
       
 20497 void CAknFepManager::SetChangeModeByShiftAndSpace( TBool aFlag )
       
 20498     {
       
 20499     iShiftAndSpace = aFlag;
       
 20500     }
       
 20501 
       
 20502 void CAknFepManager::HideExactWordPopUp()
       
 20503 	{
       
 20504 	iExactWordPopupContent->HidePopUp();	
       
 20505 	}
       
 20506 
       
 20507 TBool CAknFepManager::IsExactWordPopUpShown()
       
 20508 	{
       
 20509 return iExactWordPopupContent->IsPopUpVisible();	
       
 20510 	}
       
 20511 void CAknFepManager::StopDisplayingMenuBar()
       
 20512     {
       
 20513     if (iEditMenuBar)
       
 20514         {
       
 20515         iEditMenuBar->StopDisplayingMenuBar();
       
 20516         iEditMenuBar = NULL;
       
 20517         }
       
 20518 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__    
       
 20519     if (iOptionsMenuBar)
       
 20520         {
       
 20521         iOptionsMenuBar->StopDisplayingMenuBar();
       
 20522         iOptionsMenuBar = NULL;
       
 20523         }
       
 20524 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__   
       
 20525     }
       
 20526 
       
 20527 void CAknFepManager::SetQwertyModeToInputcapbility()
       
 20528     {
       
 20529     if ( iSharedDataInterface->QwertyInputMode() )
       
 20530         {
       
 20531         SetExtendedInputCapabilities( ExtendedInputCapabilities() |
       
 20532             CAknExtendedInputCapabilities::EInputEditorQwertyInputActive  );
       
 20533         }
       
 20534     else
       
 20535         {
       
 20536         SetExtendedInputCapabilities( ExtendedInputCapabilities() &
       
 20537             ~CAknExtendedInputCapabilities::EInputEditorQwertyInputActive  );
       
 20538         }
       
 20539     }
       
 20540 void CAknFepManager::SetExtendedInputCapabilities( TUint aCapabilities)
       
 20541     {
       
 20542     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 20543 
       
 20544     if ( mop && iInputCapabilities.FepAwareTextEditor() )//IsFepAwareTextEditor()
       
 20545         {
       
 20546         CAknExtendedInputCapabilities* extendedInputCapabilities =
       
 20547         mop->MopGetObject( extendedInputCapabilities );
       
 20548 
       
 20549         if ( extendedInputCapabilities )
       
 20550             {
       
 20551             extendedInputCapabilities->SetCapabilities( aCapabilities );
       
 20552             }
       
 20553         }
       
 20554 
       
 20555     return;
       
 20556     }
       
 20557 
       
 20558 void CAknFepManager::PrepareFepAfterDialogExitL(TUid aFepUid)
       
 20559     {
       
 20560     // This ensures that on 3rd party fep change we do not have access to other fep variables
       
 20561     if (aFepUid != CCoeEnv::Static()->FepUid())
       
 20562         {
       
 20563 		// In case the fep has changed, then leave
       
 20564         User::Leave(KErrNone);
       
 20565         }
       
 20566 	// Once the editor which launches a dialog is destroyed, this flag is set
       
 20567 	// In case we have any dialog launched we leave as the underneath editor is
       
 20568 	// destroyed
       
 20569     if (IsExtendedFlagSet(EExtendedFlagEdwinEditorDestroyed))
       
 20570         {
       
 20571         if(!iFepAwareDialogParentEditor)
       
 20572             {
       
 20573 			// For Eg: Messaging editor launches spell query which inturn launches
       
 20574 			// SCT. Then don't clear the flag once we dismiss SCT because we even
       
 20575 			// need to dismiss spell query dialog.
       
 20576             ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 20577             }       
       
 20578         User::Leave(KErrNone);
       
 20579         }
       
 20580     if(!iFepAwareDialogParentEditor)
       
 20581         {
       
 20582         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 20583         }    
       
 20584     }
       
 20585 
       
 20586 void CAknFepManager::PrepareFepForFepAwareDialogLaunch()
       
 20587     {
       
 20588     iFepAwareDialogParentEditor = EditorState();
       
 20589     SetExtendedFlag(EExtendedFlagFepAwareDialogLaunched);
       
 20590     }
       
 20591 
       
 20592 void CAknFepManager::PrepareFepAfterFepAwareDialogExitL(TUid aFepUid)
       
 20593     {
       
 20594     // This ensures that on 3rd party fep change we do not have access to other fep variables
       
 20595     if (aFepUid != CCoeEnv::Static()->FepUid())
       
 20596         {
       
 20597         // In case the fep has changed, then leave
       
 20598         User::Leave(KErrNone);
       
 20599         }    
       
 20600     iFepAwareDialogParentEditor = NULL;
       
 20601     ClearExtendedFlag(EExtendedFlagFepAwareDialogLaunched);
       
 20602     }
       
 20603 
       
 20604 void CAknFepManager::ConvertCharToKey(TChar aChar, TUint16& aKey) const
       
 20605     {
       
 20606     aKey = 0;
       
 20607 	
       
 20608 	if (!iPtiEngine)
       
 20609 		return;
       
 20610 		
       
 20611     CPtiCoreLanguage* lang = (CPtiCoreLanguage*)iPtiEngine->GetLanguage(iLanguageCapabilities.iInputLanguageCode);
       
 20612     TPtiEngineInputMode inputMode = iPtiEngine->InputMode();
       
 20613     
       
 20614     if (!lang)
       
 20615         return;
       
 20616 
       
 20617     const TBool vietnamese = (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese);
       
 20618 
       
 20619     MPtiKeyMappings* map;
       
 20620     if (inputMode == EPtiEngineQwerty || inputMode == EPtiEngineQwertyPredictive)
       
 20621         {
       
 20622         map = lang->GetQwertyKeymappings();
       
 20623         }
       
 20624     else if( inputMode == EPtiEngineHalfQwerty || inputMode == EPtiEngineHalfQwertyPredictive )
       
 20625         {
       
 20626         map = lang->GetHalfQwertyKeymappings();
       
 20627         }
       
 20628     else    
       
 20629         {
       
 20630         map = lang->GetKeymappings();
       
 20631         }
       
 20632 
       
 20633     if (!map)
       
 20634         {
       
 20635         return;
       
 20636         }   
       
 20637 
       
 20638     TUint16 ch;
       
 20639     ch = (TUint16)map->KeyForCharacter(aChar); 
       
 20640     if (!ch && vietnamese)
       
 20641         {
       
 20642         // This may be Vietnamese tone mark or an accented character which isn't listed
       
 20643         // in keymappings. 
       
 20644         ch = RemapVietnameseAccentedCharacter(aChar);
       
 20645         }
       
 20646 
       
 20647     aKey = ch;
       
 20648     }
       
 20649 
       
 20650 // ---------------------------------------------------------------------------
       
 20651 // LOCAL METHODS
       
 20652 // 
       
 20653 // ---------------------------------------------------------------------------
       
 20654 //     
       
 20655 const TInt KVietKeyMarker = 0xffff;
       
 20656 const TUint16 vietnameseAccents[] =
       
 20657     {
       
 20658     KVietKeyMarker, EPtiKey2, // For key 2, a-based    
       
 20659     0x00c1,	0x00c0, 0x1ea2, 0x00c3, 0x1ea0,
       
 20660     0x00e1, 0x00e0, 0x1ea3, 0x00e3, 0x1ea1,
       
 20661     0x0102, 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6,
       
 20662     0x0103, 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7,
       
 20663     0x00c2, 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac,
       
 20664     0x00e2, 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead, 
       
 20665 
       
 20666     KVietKeyMarker, EPtiKey3, // For key 3, e-based    
       
 20667     0x00c9,	0x00c8, 0x1eba, 0x1ebc, 0x1eb8,
       
 20668     0x00e9, 0x00e8, 0x1ebb, 0x1ebd, 0x1eb9,
       
 20669     0x00ca, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6,
       
 20670     0x00ea, 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7,
       
 20671 
       
 20672     KVietKeyMarker, EPtiKey4, // For key 4, i-based    
       
 20673     0x00cd,	0x00cc, 0x1ec8, 0x0128, 0x1eca,
       
 20674     0x00ed, 0x00ec, 0x1ec9, 0x0129, 0x1ecb,
       
 20675     
       
 20676     KVietKeyMarker, EPtiKey6, // For key 6, o-based    
       
 20677     0x00d3,	0x00d2, 0x1ece, 0x00d5, 0x1ecc,
       
 20678     0x00f3, 0x00f2, 0x1ecf, 0x00f5, 0x1ecd,
       
 20679     0x00d4, 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8,
       
 20680     0x00f4, 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9,
       
 20681     0x01a0, 0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2,
       
 20682     0x01a1, 0x1edb, 0x1edd, 0x1edf, 0x1ee1, 0x1ee3, 
       
 20683     0
       
 20684     }; 
       
 20685 
       
 20686 
       
 20687 // ---------------------------------------------------------------------------
       
 20688 // RemapVietnameseAccentedCharacter
       
 20689 // 
       
 20690 // ---------------------------------------------------------------------------
       
 20691 // 
       
 20692 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr)
       
 20693 	{
       
 20694 	// Check tone marks first.	
       
 20695 	switch (aChr)
       
 20696 		{
       
 20697 		case 0x0301:
       
 20698 		     return EPtiKey2;
       
 20699 		case 0x0300:
       
 20700 		     return EPtiKey3;
       
 20701 		case 0x0309:
       
 20702 		     return EPtiKey4;		     
       
 20703 		case 0x0303:
       
 20704 			 return EPtiKey5;			
       
 20705 		case 0x0323:
       
 20706 			 return EPtiKey6;						 
       
 20707 		default:
       
 20708 			break; 	
       
 20709 		}	 
       
 20710 	
       
 20711 	TInt ret = 0;
       
 20712 	
       
 20713 	for (const TUint16* ptr = vietnameseAccents; *ptr != 0; ptr++)
       
 20714 		{
       
 20715 		if (*ptr == KVietKeyMarker)
       
 20716 			{
       
 20717 			ret = ptr[1];
       
 20718 			ptr++;
       
 20719 			}
       
 20720 		else
       
 20721 			{
       
 20722 			if (*ptr == aChr)
       
 20723 				{
       
 20724 				break;
       
 20725 				}
       
 20726 			}			
       
 20727 		}
       
 20728 		
       
 20729 	return ret;	 		
       
 20730 	}
       
 20731 
       
 20732 // End of file