|
1 /* |
|
2 * Copyright (c) 2000-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 EDITORPLAINTEXTUNDO_H_ |
|
20 #define EDITORPLAINTEXTUNDO_H_ |
|
21 |
|
22 #include "unified_editor.h" |
|
23 |
|
24 namespace UndoSystem |
|
25 { |
|
26 class CCommandManager; |
|
27 class MNotUndoableGatekeeper; |
|
28 } |
|
29 |
|
30 class CEditorPlainTextCommandFactory; |
|
31 |
|
32 /** |
|
33 MUnifiedEditor decorator that adds undo functionality to plain text editors. |
|
34 It passes commands transparently to the editor it is constructed upon, while |
|
35 storing the operations so that they can be undone and redone. Calling a |
|
36 non-const method of MUnifiedEditor wipes all 'Redo' operations. |
|
37 The undo and redo operations are only guaranteed to be accurate if the |
|
38 underlying editor satisfies certain conditions. |
|
39 |
|
40 @since App-frameworks6.1 |
|
41 @internalComponent |
|
42 */ |
|
43 class CEditorPlainTextWithUndo : public CBase, public MUnifiedEditor, |
|
44 private MUnifiedEditor::MClipboardSupport |
|
45 { |
|
46 public: |
|
47 ~CEditorPlainTextWithUndo(); |
|
48 |
|
49 /** |
|
50 * Creates a CEditorPlainTextWithUndo, using the aSharedUndoSystem. |
|
51 * This allows many objects to stay in synchronization when each is |
|
52 * accessed seperately. |
|
53 * The aEditor is not owned. |
|
54 * Undo functionality is accessed only via the aSharedUndoSystem |
|
55 * object. |
|
56 */ |
|
57 IMPORT_C static CEditorPlainTextWithUndo* NewL(MUnifiedEditor& aEditor, |
|
58 UndoSystem::CCommandManager* aSharedUndoSystem); |
|
59 |
|
60 // From MUnifiedEditor |
|
61 void InsertTextL(TInt aPos, const TDesC& aText, const TDesC* aStyle, |
|
62 const TTmCharFormatLayer*, const RTmParFormatLayer*); |
|
63 void DeleteTextL(TInt aPos,TInt aLength); |
|
64 MTmOptionalInterface* Interface(TUint aId); |
|
65 |
|
66 // The following methods are forwarded to the base editor |
|
67 TInt DocumentLength() const; |
|
68 void GetText(TInt aPos, TPtrC& aText) const; |
|
69 void GetBaseFormatL(TTmCharFormat&, RTmParFormat&) const; |
|
70 void GetCharFormat(TInt aPos, TFormatLevel aLevel, |
|
71 TTmCharFormatLayer& aFormat,TInt& aRunLength) const; |
|
72 void GetParFormatL(TInt aPos, TFormatLevel aLevel, |
|
73 RTmParFormatLayer& aFormat, TInt& aRunLength) const; |
|
74 void SetBaseFormatL(const TTmCharFormat&, const RTmParFormat&); |
|
75 void SetCharFormatL(TInt aPos, TInt aLength, const TTmCharFormatLayer&); |
|
76 void SetParFormatL(TInt aPos, TInt aLength, const RTmParFormatLayer&); |
|
77 void DeleteCharFormatL(TInt aPos, TInt aLength); |
|
78 void DeleteParFormatL(TInt aPos, TInt aLength); |
|
79 |
|
80 private: |
|
81 CEditorPlainTextWithUndo(); |
|
82 void ConstructL(MUnifiedEditor& aEditorBasedOn, |
|
83 UndoSystem::CCommandManager& aSharedUndoSystem); |
|
84 |
|
85 // from MUnifiedEditor::MClipboardSupport |
|
86 void CopyToStoreL(CStreamStore&, CStreamDictionary&, TInt, TInt) const; |
|
87 void PasteFromStoreL(const CStreamStore&, const CStreamDictionary&, TInt); |
|
88 |
|
89 CEditorPlainTextCommandFactory* iFactory; |
|
90 MUnifiedEditor* iBaseEditor; |
|
91 UndoSystem::CCommandManager* iCommandManager; |
|
92 }; |
|
93 |
|
94 #endif // EDITORPLAINTEXTUNDO_H_ |
|
95 |