webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp
changeset 26 cb62a4f66ebe
parent 25 0ed94ceaa377
child 27 6297cdf66332
equal deleted inserted replaced
25:0ed94ceaa377 26:cb62a4f66ebe
    52 #include <eikpanic.h>
    52 #include <eikpanic.h>
    53 #include <aknedsts.h>
    53 #include <aknedsts.h>
    54 #include <aknutils.h>
    54 #include <aknutils.h>
    55 #include "Text.h"
    55 #include "Text.h"
    56 
    56 
       
    57 #define KLineEnterChar 0x21b2
       
    58 
    57 using namespace WebCore;
    59 using namespace WebCore;
    58 
    60 
    59 static const int kInfinite = -1;
    61 static const int kInfinite = -1;
    60 _LIT(KBlankDesC," ");
    62 _LIT(KBlankDesC," ");
    61 
    63 
    83     // Set alignment on m_ExtendedInputCapabilities, yes it checks if NULL
    85     // Set alignment on m_ExtendedInputCapabilities, yes it checks if NULL
    84     // The EInputEditorAlignXXX flags are defined for 5.0+ platforms
    86     // The EInputEditorAlignXXX flags are defined for 5.0+ platforms
    85 #if defined(BRDO_BROWSER_50_FF)
    87 #if defined(BRDO_BROWSER_50_FF)
    86     SetAlignment( CAknExtendedInputCapabilities::EInputEditorAlignBidi );
    88     SetAlignment( CAknExtendedInputCapabilities::EInputEditorAlignBidi );
    87 #endif
    89 #endif
    88 	EnableCcpu(ETrue);
    90     TRAP_IGNORE( EnableCcpuL() );
    89 }
    91 }
    90 
    92 
    91 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    92 // ~CWebFepTextEditor
    94 // ~CWebFepTextEditor
    93 //
    95 //
    97     {
    99     {
    98     delete m_state;
   100     delete m_state;
    99     delete m_inlineEditText;
   101     delete m_inlineEditText;
   100     delete m_textFormatMask;
   102     delete m_textFormatMask;
   101 	delete m_ExtendedInputCapabilities;
   103 	delete m_ExtendedInputCapabilities;
       
   104 	delete m_CcpuSupport;
   102     }
   105     }
   103 
   106 
   104 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   105 // CreateTextFormatMask
   108 // CreateTextFormatMask
   106 //
   109 //
   339 //
   342 //
   340 //
   343 //
   341 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   342 void CWebFepTextEditor::CancelFepInlineEdit()
   345 void CWebFepTextEditor::CancelFepInlineEdit()
   343 {
   346 {
       
   347     if (IsTextAreaFocused()) {
       
   348         if (m_inlineEditText && DocumentLengthForFep() < DocumentMaximumLengthForFep()) {
       
   349             HBufC* tempBuf = HBufC::NewLC(DocumentLengthForFep());
       
   350             TPtr ptr(tempBuf->Des());
       
   351             GetEditorContentForFep(ptr, 0, DocumentLengthForFep());
       
   352             TInt position = ptr.Locate(KLineEnterChar);
       
   353             if(position != KErrNotFound){
       
   354                 TRAP_IGNORE(m_webView->fepTextEditor()->DoCommitFepInlineEditL());
       
   355                 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
   356 				if(frame){
       
   357                 	frame->editor()->execCommand("BackwardDelete");
       
   358 				}
       
   359             }
       
   360             CleanupStack::PopAndDestroy();
       
   361         }
       
   362     }
   344 }
   363 }
   345 
   364 
   346 // -----------------------------------------------------------------------------
   365 // -----------------------------------------------------------------------------
   347 // DocumentLengthForFep
   366 // DocumentLengthForFep
   348 //
   367 //
   702     else {
   721     else {
   703         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap);
   722         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap);
   704     	}
   723     	}
   705 
   724 
   706     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
   725     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
       
   726     if (m_CcpuSupport)
       
   727     {
       
   728         TRAP_IGNORE(m_CcpuSupport->HandleFocusChangeL());
       
   729     }
   707 }
   730 }
   708 
   731 
   709 // -----------------------------------------------------------------------------
   732 // -----------------------------------------------------------------------------
   710 // UpdateInputModeState
   733 // UpdateInputModeState
   711 //
   734 //
   771     // MAknEdStateObserver::EAknCursorPositionChanged
   794     // MAknEdStateObserver::EAknCursorPositionChanged
   772 
   795 
   773     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   796     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   774     if ( state ) {
   797     if ( state ) {
   775         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
   798         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
       
   799 		if (m_CcpuSupport)
       
   800 		{
       
   801 			TRAP_IGNORE(m_CcpuSupport->HandleSelectionChangeL());
       
   802 		}
   776     }
   803     }
   777 }
   804 }
   778 
   805 
   779 // -----------------------------------------------------------------------------
   806 // -----------------------------------------------------------------------------
   780 // GetStateFromFormatMask
   807 // GetStateFromFormatMask
  1067 // -----------------------------------------------------------------------------
  1094 // -----------------------------------------------------------------------------
  1068 TBool CWebFepTextEditor::CcpuCanCut() const
  1095 TBool CWebFepTextEditor::CcpuCanCut() const
  1069 {
  1096 {
  1070     TCursorSelection selection;
  1097     TCursorSelection selection;
  1071     GetCursorSelectionForFep(selection);
  1098     GetCursorSelectionForFep(selection);
  1072     return selection.Length();
  1099     return m_CcpuSupport && selection.Length();
  1073 }
  1100 }
  1074 
  1101 
  1075 // -----------------------------------------------------------------------------
  1102 // -----------------------------------------------------------------------------
  1076 // CcpuCutL
  1103 // CcpuCutL
  1077 //
  1104 //
  1080 void CWebFepTextEditor::CcpuCutL()
  1107 void CWebFepTextEditor::CcpuCutL()
  1081 {
  1108 {
  1082     PlaceDataOnClipboardL();
  1109     PlaceDataOnClipboardL();
  1083     TCursorSelection selection;
  1110     TCursorSelection selection;
  1084     GetCursorSelectionForFep(selection);
  1111     GetCursorSelectionForFep(selection);
       
  1112     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
  1113     if (frame) {      
       
  1114         frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
       
  1115             CharacterGranularity, false, true);
       
  1116         }
       
  1117     HandleUpdateCursor();
  1085 }
  1118 }
  1086 
  1119 
  1087 // -----------------------------------------------------------------------------
  1120 // -----------------------------------------------------------------------------
  1088 // CcpuCanCopy
  1121 // CcpuCanCopy
  1089 //
  1122 //
  1091 // -----------------------------------------------------------------------------
  1124 // -----------------------------------------------------------------------------
  1092 TBool CWebFepTextEditor::CcpuCanCopy() const
  1125 TBool CWebFepTextEditor::CcpuCanCopy() const
  1093 {
  1126 {
  1094     TCursorSelection selection;
  1127     TCursorSelection selection;
  1095     GetCursorSelectionForFep(selection);
  1128     GetCursorSelectionForFep(selection);
  1096     return selection.Length();
  1129     return m_CcpuSupport && selection.Length();
  1097 }
  1130 }
  1098 
  1131 
  1099 // -----------------------------------------------------------------------------
  1132 // -----------------------------------------------------------------------------
  1100 // CcpuCopyL
  1133 // CcpuCopyL
  1101 //
  1134 //
  1112 //
  1145 //
  1113 // -----------------------------------------------------------------------------
  1146 // -----------------------------------------------------------------------------
  1114 TBool CWebFepTextEditor::CcpuCanPaste() const
  1147 TBool CWebFepTextEditor::CcpuCanPaste() const
  1115 {
  1148 {
  1116     TRAPD(err, DoCcpuCanPasteL());
  1149     TRAPD(err, DoCcpuCanPasteL());
  1117     return err == KErrNone;
  1150     return (err == KErrNone) && m_CcpuSupport;
  1118 }
  1151 }
  1119 
  1152 
  1120 // -----------------------------------------------------------------------------
  1153 // -----------------------------------------------------------------------------
  1121 // CcpuPasteL
  1154 // CcpuPasteL
  1122 //
  1155 //
  1318 // -----------------------------------------------------------------------------
  1351 // -----------------------------------------------------------------------------
  1319 // EnableCcpu
  1352 // EnableCcpu
  1320 //
  1353 //
  1321 //
  1354 //
  1322 // -----------------------------------------------------------------------------
  1355 // -----------------------------------------------------------------------------
  1323 void CWebFepTextEditor::EnableCcpu(TBool aSupport)
  1356 void CWebFepTextEditor::EnableCcpuL()
  1324 {
  1357 {
       
  1358     CAknCcpuSupport* ccpu = NULL;
  1325     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1359     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1326     if(aSupport)
  1360     ccpu = new(ELeave) CAknCcpuSupport(this);
       
  1361     ccpu->SetMopParent(this);
       
  1362     CleanupStack::PushL(ccpu);
       
  1363     ccpu->ConstructL();
       
  1364     CleanupStack::Pop(ccpu);
       
  1365     delete m_CcpuSupport;
       
  1366     m_CcpuSupport = ccpu;
       
  1367     if (edwinState)
  1327         {
  1368         {
  1328         edwinState->SetCcpuState(this);
  1369         edwinState->SetCcpuState(this);    
  1329         }
  1370         edwinState->SetMenu();
  1330     else
  1371         if (edwinState->MenuBar())
  1331         {
  1372             edwinState->MenuBar()->SetEditMenuObserver( m_CcpuSupport );
  1332         edwinState->SetCcpuState(NULL);
  1373         }        
  1333         }
       
  1334 }
  1374 }
  1335 
  1375 
  1336 // -----------------------------------------------------------------------------
  1376 // -----------------------------------------------------------------------------
  1337 // findPrevSiblingTextLen
  1377 // findPrevSiblingTextLen
  1338 //
  1378 //
  1413         }
  1453         }
  1414         m_ExtendedInputCapabilities->SetCapabilities(capabilities);
  1454         m_ExtendedInputCapabilities->SetCapabilities(capabilities);
  1415     }
  1455     }
  1416 }
  1456 }
  1417 
  1457 
       
  1458 // -----------------------------------------------------------------------------
       
  1459 // FocusChanging
       
  1460 //
       
  1461 // Called when the focus of the node changes, to commit the text 
       
  1462 // -----------------------------------------------------------------------------
       
  1463 void CWebFepTextEditor::FocusChanging()
       
  1464     { 
       
  1465     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
       
  1466     if ( state ) {
       
  1467         TRAP_IGNORE( state->ReportAknEdStateEventL(MAknEdStateObserver::EAknSyncEdwinState ) );
       
  1468     }
       
  1469     CommitFepInlineEditL(*CEikonEnv::Static());
       
  1470     CancelEditingMode();    
       
  1471     } 
       
  1472 
       
  1473