sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef EDITORPLAINTEXTCOMMANDS_H_
|
sl@0
|
20 |
#define EDITORPLAINTEXTCOMMANDS_H_
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "unified_editor.h"
|
sl@0
|
23 |
#include "UniqueInstance.h"
|
sl@0
|
24 |
#include "UndoSystem.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
namespace LocalInFile
|
sl@0
|
27 |
{
|
sl@0
|
28 |
/**
|
sl@0
|
29 |
@internalComponent
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
const TInt KMaxCharsInSingleCommand = 20;
|
sl@0
|
32 |
const TInt KUndoDllUid = 0x1000902D;
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
using namespace LocalInFile;
|
sl@0
|
36 |
|
sl@0
|
37 |
namespace UndoSystem
|
sl@0
|
38 |
{
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
* Takes two commands and returns one, which when executed will
|
sl@0
|
41 |
* achieve the result of executing first aRight, then aLeft.
|
sl@0
|
42 |
* Either argument may be null, indicating no effect of execution.
|
sl@0
|
43 |
* In the event of a leave, aRight will be destroyed, however
|
sl@0
|
44 |
* aLeft must be protected by the calling function.
|
sl@0
|
45 |
* Ownership of aLeft is passed into the function if it exits
|
sl@0
|
46 |
* cleanly, and ownership of the return value is passed back
|
sl@0
|
47 |
* to the calling function.
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
CCommand* CoalesceL(CCommand* aLeft, CCommand* aRight);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
// all the combinable commands:
|
sl@0
|
53 |
class CEditorCommandInsertTextAndFormat;
|
sl@0
|
54 |
class CEditorCommandDeleteText;
|
sl@0
|
55 |
class CEditorCommandInsertPlainText;
|
sl@0
|
56 |
class CEditorCommandDeletePlainText;
|
sl@0
|
57 |
class CEditorCommandDeleteCharFormat;
|
sl@0
|
58 |
class CEditorCommandDeleteParFormat;
|
sl@0
|
59 |
|
sl@0
|
60 |
/**
|
sl@0
|
61 |
* Editor command is the base class for all the MUnifiedEditor commands.
|
sl@0
|
62 |
*
|
sl@0
|
63 |
* @internalComponent
|
sl@0
|
64 |
* @since App-frameworks6.1
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
NONSHARABLE_CLASS(CEditorCommand) : public UndoSystem::CSingleCommand
|
sl@0
|
67 |
{
|
sl@0
|
68 |
public:
|
sl@0
|
69 |
TUid FamilyUid() const;
|
sl@0
|
70 |
|
sl@0
|
71 |
// downcast to combinable internal commands
|
sl@0
|
72 |
virtual CEditorCommandInsertTextAndFormat*
|
sl@0
|
73 |
CastToCEditorCommandInsertTextAndFormat();
|
sl@0
|
74 |
virtual CEditorCommandDeleteText*
|
sl@0
|
75 |
CastToCEditorCommandDeleteText();
|
sl@0
|
76 |
virtual CEditorCommandInsertPlainText*
|
sl@0
|
77 |
CastToCEditorCommandInsertPlainText();
|
sl@0
|
78 |
virtual CEditorCommandDeletePlainText*
|
sl@0
|
79 |
CastToCEditorCommandDeletePlainText();
|
sl@0
|
80 |
virtual CEditorCommandDeleteCharFormat*
|
sl@0
|
81 |
CastToCEditorCommandDeleteCharFormat();
|
sl@0
|
82 |
virtual CEditorCommandDeleteParFormat*
|
sl@0
|
83 |
CastToCEditorCommandDeleteParFormat();
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
//
|
sl@0
|
87 |
// command prototypes
|
sl@0
|
88 |
//
|
sl@0
|
89 |
|
sl@0
|
90 |
/**
|
sl@0
|
91 |
* Prototype command for inserting text with specified character and paragraph
|
sl@0
|
92 |
* format.
|
sl@0
|
93 |
*
|
sl@0
|
94 |
* @internalComponent
|
sl@0
|
95 |
* @since App-frameworks6.1
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
NONSHARABLE_CLASS(CEditorCommandInsertPlainTextProto) : public CEditorCommand
|
sl@0
|
98 |
{
|
sl@0
|
99 |
MUnifiedEditor& iTarget;
|
sl@0
|
100 |
TInt iPos;
|
sl@0
|
101 |
const TDesC* iText;
|
sl@0
|
102 |
|
sl@0
|
103 |
public:
|
sl@0
|
104 |
CEditorCommandInsertPlainTextProto(MUnifiedEditor& aTarget)
|
sl@0
|
105 |
: iTarget(aTarget) {}
|
sl@0
|
106 |
void Set(TInt aPos, const TDesC& aText);
|
sl@0
|
107 |
|
sl@0
|
108 |
UndoSystem::CCommand* CreateInverseL() const;
|
sl@0
|
109 |
TInt ExecuteL() const;
|
sl@0
|
110 |
|
sl@0
|
111 |
TBool PrepareToAddInverseToLastL(UndoSystem::CSingleCommand& aLastCommand) const;
|
sl@0
|
112 |
void AddInverseToLast(UndoSystem::CSingleCommand& aLastCommand) const;
|
sl@0
|
113 |
};
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
* Prototype command for deleting text.
|
sl@0
|
117 |
*
|
sl@0
|
118 |
* @internalComponent
|
sl@0
|
119 |
* @since App-frameworks6.1
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
NONSHARABLE_CLASS(CEditorCommandDeletePlainTextProto) : public CEditorCommand
|
sl@0
|
122 |
{
|
sl@0
|
123 |
enum { KMaxCombinableReinsertCharacters = 20 };
|
sl@0
|
124 |
|
sl@0
|
125 |
MUnifiedEditor& iTarget;
|
sl@0
|
126 |
TInt iPos;
|
sl@0
|
127 |
TInt iLength;
|
sl@0
|
128 |
// For adding inverse to last command
|
sl@0
|
129 |
mutable TBuf<KMaxCombinableReinsertCharacters> iDeletedText;
|
sl@0
|
130 |
|
sl@0
|
131 |
public:
|
sl@0
|
132 |
CEditorCommandDeletePlainTextProto(MUnifiedEditor& aTarget)
|
sl@0
|
133 |
: iTarget(aTarget) {}
|
sl@0
|
134 |
void Set(TInt aPos, TInt aLength);
|
sl@0
|
135 |
|
sl@0
|
136 |
UndoSystem::CCommand* CreateInverseL() const;
|
sl@0
|
137 |
TInt ExecuteL() const;
|
sl@0
|
138 |
|
sl@0
|
139 |
TBool PrepareToAddInverseToLastL(UndoSystem::CSingleCommand& aLastCommand) const;
|
sl@0
|
140 |
void AddInverseToLast(UndoSystem::CSingleCommand& aLastCommand) const;
|
sl@0
|
141 |
};
|
sl@0
|
142 |
|
sl@0
|
143 |
/**
|
sl@0
|
144 |
* Implementation of plain text insertion for use by plain & rich text
|
sl@0
|
145 |
* insertion commands.
|
sl@0
|
146 |
*
|
sl@0
|
147 |
* @internalComponent
|
sl@0
|
148 |
* @since App-frameworks6.1
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
class TEditorInsertPlainTextImpl
|
sl@0
|
151 |
{
|
sl@0
|
152 |
MUnifiedEditor& iTarget;
|
sl@0
|
153 |
TInt iPos;
|
sl@0
|
154 |
TBuf<KMaxCharsInSingleCommand> iText;
|
sl@0
|
155 |
public:
|
sl@0
|
156 |
TEditorInsertPlainTextImpl(MUnifiedEditor& aTarget, TInt aPos, const TDesC& aText)
|
sl@0
|
157 |
: iTarget(aTarget), iPos(aPos), iText(aText) {}
|
sl@0
|
158 |
MUnifiedEditor& Target() const { return iTarget; }
|
sl@0
|
159 |
const TDesC& Text() const { return iText; }
|
sl@0
|
160 |
TInt Pos() const { return iPos; }
|
sl@0
|
161 |
TInt ExecuteL(const TDesC* aStyle, const TTmCharFormatLayer* aChar,
|
sl@0
|
162 |
const RTmParFormatLayer* aPar) const;
|
sl@0
|
163 |
TInt ExecuteL() const;
|
sl@0
|
164 |
TInt CanAdd(TInt aPos, const TDesC& aText, MUnifiedEditor& aTarget) const;
|
sl@0
|
165 |
void Add(TInt aPos, const TDesC& aText);
|
sl@0
|
166 |
};
|
sl@0
|
167 |
|
sl@0
|
168 |
/**
|
sl@0
|
169 |
* Implementation of plain text deletion for use by plain & rich text
|
sl@0
|
170 |
* deletion commands.
|
sl@0
|
171 |
* Used only in the implementation of command objects.
|
sl@0
|
172 |
*
|
sl@0
|
173 |
* @internalComponent
|
sl@0
|
174 |
* @since App-frameworks6.1
|
sl@0
|
175 |
*/
|
sl@0
|
176 |
class TEditorDeletePlainTextImpl
|
sl@0
|
177 |
{
|
sl@0
|
178 |
MUnifiedEditor& iTarget;
|
sl@0
|
179 |
TInt iPos;
|
sl@0
|
180 |
TInt iLength;
|
sl@0
|
181 |
|
sl@0
|
182 |
public:
|
sl@0
|
183 |
TEditorDeletePlainTextImpl(MUnifiedEditor& aTarget, TInt aPos,
|
sl@0
|
184 |
TInt aLength) : iTarget(aTarget), iPos(aPos), iLength(aLength) {}
|
sl@0
|
185 |
MUnifiedEditor& Target() const { return iTarget; }
|
sl@0
|
186 |
TInt Pos() const { return iPos; }
|
sl@0
|
187 |
TInt Length() const { return iLength; }
|
sl@0
|
188 |
TInt ExecuteL() const;
|
sl@0
|
189 |
TBool CanAdd(TInt aPos, TInt aLength, MUnifiedEditor& aTarget) const;
|
sl@0
|
190 |
void Add(TInt aLength);
|
sl@0
|
191 |
};
|
sl@0
|
192 |
|
sl@0
|
193 |
/**
|
sl@0
|
194 |
* Implementation class for pasting text
|
sl@0
|
195 |
*
|
sl@0
|
196 |
* @internalComponent
|
sl@0
|
197 |
* @since App-frameworks6.1
|
sl@0
|
198 |
*/
|
sl@0
|
199 |
class TEditorPasteProtoImpl
|
sl@0
|
200 |
{
|
sl@0
|
201 |
MUnifiedEditor& iTarget;
|
sl@0
|
202 |
const CStreamStore* iStore;
|
sl@0
|
203 |
const CStreamDictionary* iStreamDictionary;
|
sl@0
|
204 |
TInt iPos;
|
sl@0
|
205 |
public:
|
sl@0
|
206 |
TEditorPasteProtoImpl(MUnifiedEditor& aTarget) : iTarget(aTarget) {}
|
sl@0
|
207 |
void Set(const CStreamStore&, const CStreamDictionary&, TInt aPos);
|
sl@0
|
208 |
TInt Pos() const { return iPos; }
|
sl@0
|
209 |
const CStreamStore& Store() const { return *iStore; }
|
sl@0
|
210 |
const CStreamDictionary& StreamDictionary() const { return *iStreamDictionary; }
|
sl@0
|
211 |
MUnifiedEditor& Target() const { return iTarget; }
|
sl@0
|
212 |
|
sl@0
|
213 |
void OpenPlainTextStreamLC(RStoreReadStream& aStream) const;
|
sl@0
|
214 |
// returns length of text in plain text stream. Leaves with KErrNotSupported
|
sl@0
|
215 |
// if there is no such stream.
|
sl@0
|
216 |
TInt LengthL() const;
|
sl@0
|
217 |
TInt ExecuteL() const;
|
sl@0
|
218 |
};
|
sl@0
|
219 |
|
sl@0
|
220 |
/**
|
sl@0
|
221 |
* Prototype command for pasting plain text.
|
sl@0
|
222 |
*
|
sl@0
|
223 |
* @internalComponent
|
sl@0
|
224 |
* @since App-frameworks6.1
|
sl@0
|
225 |
*/
|
sl@0
|
226 |
NONSHARABLE_CLASS(CEditorCommandPastePlainTextProto) : public CEditorCommand
|
sl@0
|
227 |
{
|
sl@0
|
228 |
TEditorPasteProtoImpl iImpl;
|
sl@0
|
229 |
|
sl@0
|
230 |
public:
|
sl@0
|
231 |
CEditorCommandPastePlainTextProto(MUnifiedEditor& aTarget)
|
sl@0
|
232 |
: iImpl(aTarget) {}
|
sl@0
|
233 |
void Set(const CStreamStore& aStore,
|
sl@0
|
234 |
const CStreamDictionary& aStreamDictionary,
|
sl@0
|
235 |
TInt aPos);
|
sl@0
|
236 |
|
sl@0
|
237 |
UndoSystem::CCommand* CreateInverseL() const;
|
sl@0
|
238 |
TInt ExecuteL() const;
|
sl@0
|
239 |
};
|
sl@0
|
240 |
|
sl@0
|
241 |
|
sl@0
|
242 |
#endif // EDITORPLAINTEXTCOMMANDS_H_
|