|
1 /* |
|
2 * Copyright (c) 1997-2009 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __WPTEXTED_H__ |
|
20 #define __WPTEXTED_H__ |
|
21 |
|
22 #include <techview/eikrted.h> |
|
23 #include "form_and_etext_editor.h" |
|
24 #include "EditorUndo.h" |
|
25 #include "UndoSystem.h" |
|
26 |
|
27 class CWordUndoGatekeeper : public CBase, public UndoSystem::MNotUndoableGatekeeper |
|
28 /** |
|
29 @internalComponent |
|
30 */ |
|
31 { |
|
32 // from MNotUndoableGatekeeper |
|
33 TBool AllowNotUndoableL(TInt aReason); |
|
34 }; |
|
35 |
|
36 class CWordTextEditor : public CEikRichTextEditor, public MUnifiedEditor |
|
37 /** |
|
38 @internalComponent |
|
39 */ |
|
40 { |
|
41 public: |
|
42 enum TAttributeValue { EAttributeUndefined = 0, EAttributeSet = 1, |
|
43 EAttributeClear = 2, EAttributeIndeterminate = 3 }; |
|
44 CWordTextEditor(const TGulBorder& aBorder); |
|
45 ~CWordTextEditor(); |
|
46 MUnifiedEditor& UnifiedEditor(); |
|
47 const MUnifiedEditor& UnifiedEditor() const; |
|
48 |
|
49 void InitialiseUnifiedEditorL(); |
|
50 void InsertCharacterL(TChar aCharacter); |
|
51 TBool DeleteSelectionL(); |
|
52 void DeleteLeftL(); |
|
53 void DeleteRightL(); |
|
54 void HighlightL(TUint aEffects); |
|
55 void RemoveHighlightL(TUint aEffects); |
|
56 TAttributeValue IsHighlighted(TUint aEffects) const; |
|
57 void ToggleHighlightL(TUint aEffects); |
|
58 inline void RedoL(); |
|
59 inline TBool CanRedo() const; |
|
60 |
|
61 TInt ClipboardPasteL(); |
|
62 void ClipboardCutL(); |
|
63 void ClipboardCopyL() const; |
|
64 |
|
65 void InsertFromHtmlFileL(const TDesC& aFileName); |
|
66 |
|
67 public: // functions overloading non-virtual functions in base classes |
|
68 inline void UndoL(); |
|
69 inline TBool CanUndo() const; |
|
70 void BoldItalicUnderlineEventL(TInt aFontFlag); |
|
71 |
|
72 public: // from MUnifiedEditor |
|
73 TInt DocumentLength() const; |
|
74 void GetText(TInt aPos,TPtrC& aText) const; |
|
75 void GetBaseFormatL(TTmCharFormat& aCharFormat,RTmParFormat& aParFormat) const; |
|
76 void GetCharFormat(TInt aPos,TFormatLevel aLevel,TTmCharFormatLayer& aFormat,TInt& aRunLength) const; |
|
77 void GetParFormatL(TInt aPos,TFormatLevel aLevel,RTmParFormatLayer& aFormat,TInt& aRunLength) const; |
|
78 void InsertTextL(TInt aPos,const TDesC& aText,const TDesC* aStyle=NULL, |
|
79 const TTmCharFormatLayer* aCharFormat=NULL,const RTmParFormatLayer* aParFormat=NULL); |
|
80 void DeleteTextL(TInt aPos,TInt aLength); |
|
81 void SetBaseFormatL(const TTmCharFormat& aCharFormat,const RTmParFormat& aParFormat); |
|
82 void SetCharFormatL(TInt aPos,TInt aLength,const TTmCharFormatLayer& aFormat); |
|
83 void SetParFormatL(TInt aPos,TInt aLength,const RTmParFormatLayer& aFormat); |
|
84 void DeleteCharFormatL(TInt aPos,TInt aLength); |
|
85 void DeleteParFormatL(TInt aPos,TInt aLength); |
|
86 MTmOptionalInterface* Interface(TUint aId); |
|
87 void TestRunNotUndoableCommandL(); |
|
88 void SetBookmark(); |
|
89 TBool IsAtBookmark() const; |
|
90 void ResetUndo(); |
|
91 private: // from CCoeControl |
|
92 void HandleResourceChange(TInt aType); |
|
93 void FocusChanged(TDrawNow aDrawNow); |
|
94 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
95 |
|
96 private: |
|
97 TFormAndEtextEditor iFormAndEtextEditor; |
|
98 CEditorWithUndo* iEditorWithUndo; |
|
99 UndoSystem::CCommandManager* iCommandManager; |
|
100 CWordUndoGatekeeper iGatekeeper; |
|
101 }; |
|
102 |
|
103 inline void CWordTextEditor::RedoL() |
|
104 { |
|
105 if (iEditorWithUndo) |
|
106 iEditorWithUndo->RedoL(); |
|
107 } |
|
108 inline TBool CWordTextEditor::CanRedo() const |
|
109 {return iEditorWithUndo && iEditorWithUndo->CanRedo();} |
|
110 inline void CWordTextEditor::UndoL() |
|
111 { |
|
112 if (iEditorWithUndo) |
|
113 iEditorWithUndo->UndoL(); |
|
114 } |
|
115 inline TBool CWordTextEditor::CanUndo() const |
|
116 {return iEditorWithUndo && iEditorWithUndo->CanUndo();} |
|
117 |
|
118 #endif |