epoc32/include/unified_editor.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
#ifndef __UNIFIED_EDITOR_H__
williamr@2
    23
#define __UNIFIED_EDITOR_H__ 1
williamr@2
    24
williamr@2
    25
#include <tagma.h>
williamr@2
    26
williamr@2
    27
/*
williamr@2
    28
The header file for MUnifiedEditor, an interface that unifies editing operations on backing text and layout,
williamr@2
    29
which are traditionally separated between ETEXT (backing text) and FORM (layout). It is not dependent
williamr@2
    30
on FORM or ETEXT, although there is an implementation (TFormAndTextEditor) using those components.
williamr@2
    31
*/
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
Base class for optional interfaces
williamr@2
    35
@internalComponent
williamr@2
    36
*/
williamr@2
    37
class MTmOptionalInterface
williamr@2
    38
williamr@2
    39
	{
williamr@2
    40
	};
williamr@2
    41
williamr@2
    42
/**
williamr@2
    43
UIDs for standard optional interfaces
williamr@2
    44
@internalComponent
williamr@2
    45
*/
williamr@2
    46
const TUint KUidMUnifiedEditorStyleSupport = 0x100092B6;
williamr@2
    47
const TUint KUidMUnifiedEditorPictureSupport = 0x100092B7;
williamr@2
    48
const TUint KUidMUnifiedEditorFieldSupport = 0x100092B8;
williamr@2
    49
const TUint KUidMUnifiedEditorClipboardSupport = 0x100095EF;
williamr@2
    50
williamr@2
    51
/**
williamr@2
    52
An interface class for text editing.
williamr@2
    53
williamr@2
    54
An object that supports text editing has some backing text - zero or more Unicode characters - and
williamr@2
    55
character and paragraph formats applicable to ranges of these characters. A paragraph is a sequence of characters
williamr@2
    56
terminating either at the end of the document or after the next paragraph separator, whichever comes first.
williamr@2
    57
williamr@2
    58
The format for a given position is derived from up to three formatting layers. The base layer is the lowest and
williamr@2
    59
provides default attributes. These may be optionally overridden by attributes from a named style, and these in
williamr@2
    60
turn may be overridden by specific formatting. Text editing objects may support any or none of these layers; they
williamr@2
    61
may in fact ignore all attempts to set format attributes.
williamr@2
    62
@internalComponent
williamr@2
    63
*/
williamr@2
    64
class MUnifiedEditor
williamr@2
    65
williamr@2
    66
	{
williamr@2
    67
public:
williamr@2
    68
	/**
williamr@2
    69
	 * constants used when getting formats
williamr@2
    70
	 */
williamr@2
    71
	enum TFormatLevel
williamr@2
    72
		{
williamr@2
    73
		ESpecific,			// format applied by the user
williamr@2
    74
		EEffective			// the actual format: a combination of base and specific formats
williamr@2
    75
		};
williamr@2
    76
	class MStyleSupport : public MTmOptionalInterface
williamr@2
    77
	/**
williamr@2
    78
	An optional interface to support styles
williamr@2
    79
	@internalComponent
williamr@2
    80
	*/
williamr@2
    81
		{
williamr@2
    82
	public:
williamr@2
    83
		/**
williamr@2
    84
		 * Creates a style.
williamr@2
    85
		 */
williamr@2
    86
		virtual TInt CreateStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
williamr@2
    87
		/**
williamr@2
    88
		 * Sets the attributes of a style.
williamr@2
    89
		 */
williamr@2
    90
		virtual TInt ChangeStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
williamr@2
    91
		/**
williamr@2
    92
		 * Applies the named style to the specified run of text.
williamr@2
    93
		 */
williamr@2
    94
		virtual TInt SetStyleL(TInt aPos, TInt aLength, const TDesC& aName) = 0;
williamr@2
    95
		/**
williamr@2
    96
		 * Renames a style.
williamr@2
    97
		 */
williamr@2
    98
		virtual TInt RenameStyleL(const TDesC& /*aOldName*/,const TDesC& /*aNewName*/) { return KErrNotSupported; }
williamr@2
    99
		/**
williamr@2
   100
		 * Deletes the named style.
williamr@2
   101
		 */
williamr@2
   102
		virtual TInt DeleteStyleL(const TDesC& /*aName*/) { return KErrNotSupported; }
williamr@2
   103
		/**
williamr@2
   104
		 * Get the number of named styles.
williamr@2
   105
		 */
williamr@2
   106
		virtual TInt StyleCount() const = 0;
williamr@2
   107
		/**
williamr@2
   108
		 * Gets the style set at the document position aPos. If no style is set
williamr@2
   109
		 * there return an empty string and the run length over which no style
williamr@2
   110
		 * applies.
williamr@2
   111
		 */
williamr@2
   112
		virtual void GetStyle(TInt aPos, TPtrC& aName, TInt& aRunLength) const = 0;
williamr@2
   113
		/**
williamr@2
   114
		 * Gets the attributes of a named style by completing aStyle from its
williamr@2
   115
		 * name.
williamr@2
   116
		 */
williamr@2
   117
		virtual TInt GetStyleByNameL(const TDesC& aName, RTmStyle& aStyle) const = 0;
williamr@2
   118
		/**
williamr@2
   119
		 * Gets the name and attributes of a style by index; use this in
williamr@2
   120
		 * conjunction with StyleCount to enumerate existing styles.
williamr@2
   121
		 */
williamr@2
   122
		virtual TInt GetStyleByIndexL(TInt aIndex, RTmStyle& aStyle) const = 0;
williamr@2
   123
		};
williamr@2
   124
williamr@2
   125
	/**
williamr@2
   126
	An optional interface to support embedded pictures
williamr@2
   127
	@internalComponent
williamr@2
   128
	*/
williamr@2
   129
	class MPictureSupport : public MTmOptionalInterface
williamr@2
   130
williamr@2
   131
		{
williamr@2
   132
	public:
williamr@2
   133
		/**
williamr@2
   134
		 * Inserts a picture, passing ownership in.
williamr@2
   135
		 */
williamr@2
   136
		virtual void InsertPictureL(TInt aPos, const TPictureHeader& aPictureIn) = 0;
williamr@2
   137
		/**
williamr@2
   138
		 * Deletes picture character in the text at aPos, if any. Ownership of
williamr@2
   139
		 * any picture is passed to the caller, therefore Picture(aPos,
williamr@2
   140
		 * aPictureOut) must have been called previously, and
williamr@2
   141
		 * aPictureOut.DeletePicture() must be called in the future to avoid a
williamr@2
   142
		 * memory leak.
williamr@2
   143
		 * If the character at aPos is a picture character, it will be deleted,
williamr@2
   144
		 * regardless of whether or not a picture was actually attatched.
williamr@2
   145
		 */
williamr@2
   146
		virtual void DropPictureL(TInt aPos) = 0;
williamr@2
   147
		/**
williamr@2
   148
		 * Gets the picture if any at aPos. No picture is indicated by
williamr@2
   149
		 * aPictureOut.iPictureType containing KUidNull.
williamr@2
   150
		 * Ownership of the picture is retained. Note that aPictureOut is
williamr@2
   151
		 * merely overwritten by this function: aPictureOut.DeletePicture() is
williamr@2
   152
		 * NOT called!
williamr@2
   153
		 */
williamr@2
   154
		virtual void Picture(TInt aPos, TPictureHeader& aPictureOut) const = 0;
williamr@2
   155
		};
williamr@2
   156
williamr@2
   157
	/**
williamr@2
   158
	An optional interface to support clipboard operations
williamr@2
   159
	@internalComponent 
williamr@2
   160
	*/
williamr@2
   161
	class MClipboardSupport : public MTmOptionalInterface
williamr@2
   162
	
williamr@2
   163
		{
williamr@2
   164
	public:
williamr@2
   165
		/**
williamr@2
   166
		 * Copy the text and formatting specified to the stream, updating
williamr@2
   167
		 * the dictionary as appropriate.
williamr@2
   168
		 */
williamr@2
   169
		virtual void CopyToStoreL(CStreamStore& aStore, CStreamDictionary& aDictionary,
williamr@2
   170
			TInt aPos, TInt aLength) const = 0;
williamr@2
   171
		/**
williamr@2
   172
		 * Insert text and formatting from the stream at aPos.
williamr@2
   173
		 */
williamr@2
   174
		virtual void PasteFromStoreL(const CStreamStore& aStore,
williamr@2
   175
			const CStreamDictionary& aDictionary, TInt aPos) = 0;
williamr@2
   176
		};
williamr@2
   177
williamr@2
   178
	// VIRTUAL FUNCTIONS
williamr@2
   179
williamr@2
   180
	// getters
williamr@2
   181
williamr@2
   182
	/**
williamr@2
   183
	 * Returns the optional interface with the specified UID, or 0 if it is not
williamr@2
   184
	 * supported.
williamr@2
   185
	 */
williamr@2
   186
	virtual MTmOptionalInterface* Interface(TUint /*aId*/) { return NULL; }
williamr@2
   187
	/**
williamr@2
   188
	 * Returns the length of the document in characters, not including any
williamr@2
   189
	 * notional final paragraph separator.
williamr@2
   190
	 */
williamr@2
   191
	virtual TInt DocumentLength() const = 0;
williamr@2
   192
	/**
williamr@2
   193
	 * Gets some text starting at aPos. The amount of text returned may be as
williamr@2
   194
	 * much or as little as is convenient to the implementation, but must be
williamr@2
   195
	 * at least one character. The text is raw Unicode text including any
williamr@2
   196
	 * paragraph separators.
williamr@2
   197
	 */
williamr@2
   198
	virtual void GetText(TInt aPos,TPtrC& aText) const = 0;
williamr@2
   199
	/**
williamr@2
   200
	 * Gets the base character and paragraph formats
williamr@2
   201
	 */
williamr@2
   202
	virtual void GetBaseFormatL(TTmCharFormat& aCharFormat,RTmParFormat& aParFormat) const = 0;
williamr@2
   203
	/**
williamr@2
   204
	 * Gets the specific or effective character format and the run over which
williamr@2
   205
	 * that format applies.
williamr@2
   206
	 */
williamr@2
   207
	virtual void GetCharFormat(TInt aPos,TFormatLevel aLevel,
williamr@2
   208
							   TTmCharFormatLayer& aFormat,TInt& aRunLength) const = 0;
williamr@2
   209
	/**
williamr@2
   210
	 * Gets the specific or effective paragraph format and the run over which
williamr@2
   211
	 * that format applies.
williamr@2
   212
	 */
williamr@2
   213
	virtual void GetParFormatL(TInt aPos,TFormatLevel aLevel,
williamr@2
   214
							   RTmParFormatLayer& aFormat,TInt& aRunLength) const = 0;
williamr@2
   215
williamr@2
   216
	// setters
williamr@2
   217
williamr@2
   218
	/**
williamr@2
   219
	 * Inserts text at aPos, optionally applying the specified character and
williamr@2
   220
	 * paragraph formats. Unspecified attributes take the format at the
williamr@2
   221
	 * insertion point; what this means in detail is implementation-dependent.
williamr@2
   222
	 */
williamr@2
   223
	virtual void InsertTextL(TInt aPos,const TDesC& aText,
williamr@2
   224
							 const TDesC* aStyle = NULL,
williamr@2
   225
							 const TTmCharFormatLayer* aCharFormat = NULL,
williamr@2
   226
							 const RTmParFormatLayer* aParFormat = NULL) = 0;
williamr@2
   227
	/**
williamr@2
   228
	 * Deletes aLength characters starting at aPos.
williamr@2
   229
	 */
williamr@2
   230
	virtual void DeleteTextL(TInt aPos,TInt aLength) = 0;
williamr@2
   231
	/**
williamr@2
   232
	 * Sets the base character and paragraph formats
williamr@2
   233
	 */
williamr@2
   234
	virtual void SetBaseFormatL(const TTmCharFormat& aCharFormat,const RTmParFormat& aParFormat) = 0;
williamr@2
   235
	/**
williamr@2
   236
	 * Sets specific character attributes beginning at aPos for aLength characters.
williamr@2
   237
	 */
williamr@2
   238
	virtual void SetCharFormatL(TInt aPos,TInt aLength,const TTmCharFormatLayer& aFormat) = 0;
williamr@2
   239
	/**
williamr@2
   240
	 * Sets specific paragraph attributes beginning at aPos for aLength characters.
williamr@2
   241
	 */
williamr@2
   242
	virtual void SetParFormatL(TInt aPos,TInt aLength,const RTmParFormatLayer& aFormat) = 0;
williamr@2
   243
	/**
williamr@2
   244
	 * Deletes specific character attributes beginning at aPos for aLength characters.
williamr@2
   245
	 */
williamr@2
   246
	virtual void DeleteCharFormatL(TInt aPos,TInt aLength) = 0;
williamr@2
   247
	/**
williamr@2
   248
	 * Deletes specific paragraph attributes beginning at aPos for aLength characters.
williamr@2
   249
	 */
williamr@2
   250
	virtual void DeleteParFormatL(TInt aPos,TInt aLength) = 0;
williamr@2
   251
williamr@2
   252
	// NON-VIRTUAL FUNCTIONS
williamr@2
   253
	/**
williamr@2
   254
	 * Reads text into a writable descriptor.
williamr@2
   255
	 *
williamr@2
   256
	 * @see GetText(TInt, TPtrC) const
williamr@2
   257
	 */
williamr@2
   258
	IMPORT_C void GetText(TInt aPos, TDes& aText) const;
williamr@2
   259
	/**
williamr@2
   260
	 * Returns the interface for manipulating styles, if applicable.
williamr@2
   261
	 */
williamr@2
   262
	inline MStyleSupport* StyleSupport();
williamr@2
   263
	inline const MStyleSupport* StyleSupport() const;
williamr@2
   264
	/**
williamr@2
   265
	 * Returns the interface for manipulating pictures, if applicable.
williamr@2
   266
	 */
williamr@2
   267
	inline MPictureSupport* PictureSupport();
williamr@2
   268
	inline const MPictureSupport* PictureSupport() const;
williamr@2
   269
	/**
williamr@2
   270
	 * Returns the interface for clipboard operations, if applicable.
williamr@2
   271
	 */
williamr@2
   272
	inline MClipboardSupport* ClipboardSupport();
williamr@2
   273
	inline const MClipboardSupport* ClipboardSupport() const;
williamr@2
   274
	};
williamr@2
   275
williamr@2
   276
// inline functions
williamr@2
   277
williamr@2
   278
MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport()
williamr@2
   279
	{
williamr@2
   280
	return static_cast<MStyleSupport*>(Interface(KUidMUnifiedEditorStyleSupport));
williamr@2
   281
	}
williamr@2
   282
williamr@2
   283
const MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport() const
williamr@2
   284
	{
williamr@2
   285
	return static_cast<MStyleSupport*>(
williamr@2
   286
		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorStyleSupport));
williamr@2
   287
	}
williamr@2
   288
williamr@2
   289
MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport()
williamr@2
   290
	{
williamr@2
   291
	return static_cast<MPictureSupport*>(Interface(KUidMUnifiedEditorPictureSupport));
williamr@2
   292
	}
williamr@2
   293
williamr@2
   294
const MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport() const
williamr@2
   295
	{
williamr@2
   296
	return static_cast<MPictureSupport*>(
williamr@2
   297
		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorPictureSupport));
williamr@2
   298
	}
williamr@2
   299
williamr@2
   300
MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport()
williamr@2
   301
	{
williamr@2
   302
	return static_cast<MClipboardSupport*>(Interface(KUidMUnifiedEditorClipboardSupport));
williamr@2
   303
	}
williamr@2
   304
williamr@2
   305
const MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport() const
williamr@2
   306
	{
williamr@2
   307
	return static_cast<MClipboardSupport*>(
williamr@2
   308
		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorClipboardSupport));
williamr@2
   309
	}
williamr@2
   310
williamr@2
   311
#endif // __UNIFIED_EDITOR_H__