2 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 #ifndef __UNIFIED_EDITOR_H__
23 #define __UNIFIED_EDITOR_H__ 1
28 The header file for MUnifiedEditor, an interface that unifies editing operations on backing text and layout,
29 which are traditionally separated between ETEXT (backing text) and FORM (layout). It is not dependent
30 on FORM or ETEXT, although there is an implementation (TFormAndTextEditor) using those components.
34 Base class for optional interfaces
37 class MTmOptionalInterface
43 UIDs for standard optional interfaces
46 const TUint KUidMUnifiedEditorStyleSupport = 0x100092B6;
47 const TUint KUidMUnifiedEditorPictureSupport = 0x100092B7;
48 const TUint KUidMUnifiedEditorFieldSupport = 0x100092B8;
49 const TUint KUidMUnifiedEditorClipboardSupport = 0x100095EF;
52 An interface class for text editing.
54 An object that supports text editing has some backing text - zero or more Unicode characters - and
55 character and paragraph formats applicable to ranges of these characters. A paragraph is a sequence of characters
56 terminating either at the end of the document or after the next paragraph separator, whichever comes first.
58 The format for a given position is derived from up to three formatting layers. The base layer is the lowest and
59 provides default attributes. These may be optionally overridden by attributes from a named style, and these in
60 turn may be overridden by specific formatting. Text editing objects may support any or none of these layers; they
61 may in fact ignore all attempts to set format attributes.
69 * constants used when getting formats
73 ESpecific, // format applied by the user
74 EEffective // the actual format: a combination of base and specific formats
76 class MStyleSupport : public MTmOptionalInterface
78 An optional interface to support styles
86 virtual TInt CreateStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
88 * Sets the attributes of a style.
90 virtual TInt ChangeStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
92 * Applies the named style to the specified run of text.
94 virtual TInt SetStyleL(TInt aPos, TInt aLength, const TDesC& aName) = 0;
98 virtual TInt RenameStyleL(const TDesC& /*aOldName*/,const TDesC& /*aNewName*/) { return KErrNotSupported; }
100 * Deletes the named style.
102 virtual TInt DeleteStyleL(const TDesC& /*aName*/) { return KErrNotSupported; }
104 * Get the number of named styles.
106 virtual TInt StyleCount() const = 0;
108 * Gets the style set at the document position aPos. If no style is set
109 * there return an empty string and the run length over which no style
112 virtual void GetStyle(TInt aPos, TPtrC& aName, TInt& aRunLength) const = 0;
114 * Gets the attributes of a named style by completing aStyle from its
117 virtual TInt GetStyleByNameL(const TDesC& aName, RTmStyle& aStyle) const = 0;
119 * Gets the name and attributes of a style by index; use this in
120 * conjunction with StyleCount to enumerate existing styles.
122 virtual TInt GetStyleByIndexL(TInt aIndex, RTmStyle& aStyle) const = 0;
126 An optional interface to support embedded pictures
129 class MPictureSupport : public MTmOptionalInterface
134 * Inserts a picture, passing ownership in.
136 virtual void InsertPictureL(TInt aPos, const TPictureHeader& aPictureIn) = 0;
138 * Deletes picture character in the text at aPos, if any. Ownership of
139 * any picture is passed to the caller, therefore Picture(aPos,
140 * aPictureOut) must have been called previously, and
141 * aPictureOut.DeletePicture() must be called in the future to avoid a
143 * If the character at aPos is a picture character, it will be deleted,
144 * regardless of whether or not a picture was actually attatched.
146 virtual void DropPictureL(TInt aPos) = 0;
148 * Gets the picture if any at aPos. No picture is indicated by
149 * aPictureOut.iPictureType containing KUidNull.
150 * Ownership of the picture is retained. Note that aPictureOut is
151 * merely overwritten by this function: aPictureOut.DeletePicture() is
154 virtual void Picture(TInt aPos, TPictureHeader& aPictureOut) const = 0;
158 An optional interface to support clipboard operations
161 class MClipboardSupport : public MTmOptionalInterface
166 * Copy the text and formatting specified to the stream, updating
167 * the dictionary as appropriate.
169 virtual void CopyToStoreL(CStreamStore& aStore, CStreamDictionary& aDictionary,
170 TInt aPos, TInt aLength) const = 0;
172 * Insert text and formatting from the stream at aPos.
174 virtual void PasteFromStoreL(const CStreamStore& aStore,
175 const CStreamDictionary& aDictionary, TInt aPos) = 0;
183 * Returns the optional interface with the specified UID, or 0 if it is not
186 virtual MTmOptionalInterface* Interface(TUint /*aId*/) { return NULL; }
188 * Returns the length of the document in characters, not including any
189 * notional final paragraph separator.
191 virtual TInt DocumentLength() const = 0;
193 * Gets some text starting at aPos. The amount of text returned may be as
194 * much or as little as is convenient to the implementation, but must be
195 * at least one character. The text is raw Unicode text including any
196 * paragraph separators.
198 virtual void GetText(TInt aPos,TPtrC& aText) const = 0;
200 * Gets the base character and paragraph formats
202 virtual void GetBaseFormatL(TTmCharFormat& aCharFormat,RTmParFormat& aParFormat) const = 0;
204 * Gets the specific or effective character format and the run over which
205 * that format applies.
207 virtual void GetCharFormat(TInt aPos,TFormatLevel aLevel,
208 TTmCharFormatLayer& aFormat,TInt& aRunLength) const = 0;
210 * Gets the specific or effective paragraph format and the run over which
211 * that format applies.
213 virtual void GetParFormatL(TInt aPos,TFormatLevel aLevel,
214 RTmParFormatLayer& aFormat,TInt& aRunLength) const = 0;
219 * Inserts text at aPos, optionally applying the specified character and
220 * paragraph formats. Unspecified attributes take the format at the
221 * insertion point; what this means in detail is implementation-dependent.
223 virtual void InsertTextL(TInt aPos,const TDesC& aText,
224 const TDesC* aStyle = NULL,
225 const TTmCharFormatLayer* aCharFormat = NULL,
226 const RTmParFormatLayer* aParFormat = NULL) = 0;
228 * Deletes aLength characters starting at aPos.
230 virtual void DeleteTextL(TInt aPos,TInt aLength) = 0;
232 * Sets the base character and paragraph formats
234 virtual void SetBaseFormatL(const TTmCharFormat& aCharFormat,const RTmParFormat& aParFormat) = 0;
236 * Sets specific character attributes beginning at aPos for aLength characters.
238 virtual void SetCharFormatL(TInt aPos,TInt aLength,const TTmCharFormatLayer& aFormat) = 0;
240 * Sets specific paragraph attributes beginning at aPos for aLength characters.
242 virtual void SetParFormatL(TInt aPos,TInt aLength,const RTmParFormatLayer& aFormat) = 0;
244 * Deletes specific character attributes beginning at aPos for aLength characters.
246 virtual void DeleteCharFormatL(TInt aPos,TInt aLength) = 0;
248 * Deletes specific paragraph attributes beginning at aPos for aLength characters.
250 virtual void DeleteParFormatL(TInt aPos,TInt aLength) = 0;
252 // NON-VIRTUAL FUNCTIONS
254 * Reads text into a writable descriptor.
256 * @see GetText(TInt, TPtrC) const
258 IMPORT_C void GetText(TInt aPos, TDes& aText) const;
260 * Returns the interface for manipulating styles, if applicable.
262 inline MStyleSupport* StyleSupport();
263 inline const MStyleSupport* StyleSupport() const;
265 * Returns the interface for manipulating pictures, if applicable.
267 inline MPictureSupport* PictureSupport();
268 inline const MPictureSupport* PictureSupport() const;
270 * Returns the interface for clipboard operations, if applicable.
272 inline MClipboardSupport* ClipboardSupport();
273 inline const MClipboardSupport* ClipboardSupport() const;
278 MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport()
280 return static_cast<MStyleSupport*>(Interface(KUidMUnifiedEditorStyleSupport));
283 const MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport() const
285 return static_cast<MStyleSupport*>(
286 const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorStyleSupport));
289 MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport()
291 return static_cast<MPictureSupport*>(Interface(KUidMUnifiedEditorPictureSupport));
294 const MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport() const
296 return static_cast<MPictureSupport*>(
297 const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorPictureSupport));
300 MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport()
302 return static_cast<MClipboardSupport*>(Interface(KUidMUnifiedEditorClipboardSupport));
305 const MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport() const
307 return static_cast<MClipboardSupport*>(
308 const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorClipboardSupport));
311 #endif // __UNIFIED_EDITOR_H__