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
     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 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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 
    22 #ifndef __UNIFIED_EDITOR_H__
    23 #define __UNIFIED_EDITOR_H__ 1
    24 
    25 #include <tagma.h>
    26 
    27 /*
    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.
    31 */
    32 
    33 /**
    34 Base class for optional interfaces
    35 @internalComponent
    36 */
    37 class MTmOptionalInterface
    38 
    39 	{
    40 	};
    41 
    42 /**
    43 UIDs for standard optional interfaces
    44 @internalComponent
    45 */
    46 const TUint KUidMUnifiedEditorStyleSupport = 0x100092B6;
    47 const TUint KUidMUnifiedEditorPictureSupport = 0x100092B7;
    48 const TUint KUidMUnifiedEditorFieldSupport = 0x100092B8;
    49 const TUint KUidMUnifiedEditorClipboardSupport = 0x100095EF;
    50 
    51 /**
    52 An interface class for text editing.
    53 
    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.
    57 
    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.
    62 @internalComponent
    63 */
    64 class MUnifiedEditor
    65 
    66 	{
    67 public:
    68 	/**
    69 	 * constants used when getting formats
    70 	 */
    71 	enum TFormatLevel
    72 		{
    73 		ESpecific,			// format applied by the user
    74 		EEffective			// the actual format: a combination of base and specific formats
    75 		};
    76 	class MStyleSupport : public MTmOptionalInterface
    77 	/**
    78 	An optional interface to support styles
    79 	@internalComponent
    80 	*/
    81 		{
    82 	public:
    83 		/**
    84 		 * Creates a style.
    85 		 */
    86 		virtual TInt CreateStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
    87 		/**
    88 		 * Sets the attributes of a style.
    89 		 */
    90 		virtual TInt ChangeStyleL(const RTmStyle& /*aStyle*/) { return KErrNotSupported; }
    91 		/**
    92 		 * Applies the named style to the specified run of text.
    93 		 */
    94 		virtual TInt SetStyleL(TInt aPos, TInt aLength, const TDesC& aName) = 0;
    95 		/**
    96 		 * Renames a style.
    97 		 */
    98 		virtual TInt RenameStyleL(const TDesC& /*aOldName*/,const TDesC& /*aNewName*/) { return KErrNotSupported; }
    99 		/**
   100 		 * Deletes the named style.
   101 		 */
   102 		virtual TInt DeleteStyleL(const TDesC& /*aName*/) { return KErrNotSupported; }
   103 		/**
   104 		 * Get the number of named styles.
   105 		 */
   106 		virtual TInt StyleCount() const = 0;
   107 		/**
   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
   110 		 * applies.
   111 		 */
   112 		virtual void GetStyle(TInt aPos, TPtrC& aName, TInt& aRunLength) const = 0;
   113 		/**
   114 		 * Gets the attributes of a named style by completing aStyle from its
   115 		 * name.
   116 		 */
   117 		virtual TInt GetStyleByNameL(const TDesC& aName, RTmStyle& aStyle) const = 0;
   118 		/**
   119 		 * Gets the name and attributes of a style by index; use this in
   120 		 * conjunction with StyleCount to enumerate existing styles.
   121 		 */
   122 		virtual TInt GetStyleByIndexL(TInt aIndex, RTmStyle& aStyle) const = 0;
   123 		};
   124 
   125 	/**
   126 	An optional interface to support embedded pictures
   127 	@internalComponent
   128 	*/
   129 	class MPictureSupport : public MTmOptionalInterface
   130 
   131 		{
   132 	public:
   133 		/**
   134 		 * Inserts a picture, passing ownership in.
   135 		 */
   136 		virtual void InsertPictureL(TInt aPos, const TPictureHeader& aPictureIn) = 0;
   137 		/**
   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
   142 		 * memory leak.
   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.
   145 		 */
   146 		virtual void DropPictureL(TInt aPos) = 0;
   147 		/**
   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
   152 		 * NOT called!
   153 		 */
   154 		virtual void Picture(TInt aPos, TPictureHeader& aPictureOut) const = 0;
   155 		};
   156 
   157 	/**
   158 	An optional interface to support clipboard operations
   159 	@internalComponent 
   160 	*/
   161 	class MClipboardSupport : public MTmOptionalInterface
   162 	
   163 		{
   164 	public:
   165 		/**
   166 		 * Copy the text and formatting specified to the stream, updating
   167 		 * the dictionary as appropriate.
   168 		 */
   169 		virtual void CopyToStoreL(CStreamStore& aStore, CStreamDictionary& aDictionary,
   170 			TInt aPos, TInt aLength) const = 0;
   171 		/**
   172 		 * Insert text and formatting from the stream at aPos.
   173 		 */
   174 		virtual void PasteFromStoreL(const CStreamStore& aStore,
   175 			const CStreamDictionary& aDictionary, TInt aPos) = 0;
   176 		};
   177 
   178 	// VIRTUAL FUNCTIONS
   179 
   180 	// getters
   181 
   182 	/**
   183 	 * Returns the optional interface with the specified UID, or 0 if it is not
   184 	 * supported.
   185 	 */
   186 	virtual MTmOptionalInterface* Interface(TUint /*aId*/) { return NULL; }
   187 	/**
   188 	 * Returns the length of the document in characters, not including any
   189 	 * notional final paragraph separator.
   190 	 */
   191 	virtual TInt DocumentLength() const = 0;
   192 	/**
   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.
   197 	 */
   198 	virtual void GetText(TInt aPos,TPtrC& aText) const = 0;
   199 	/**
   200 	 * Gets the base character and paragraph formats
   201 	 */
   202 	virtual void GetBaseFormatL(TTmCharFormat& aCharFormat,RTmParFormat& aParFormat) const = 0;
   203 	/**
   204 	 * Gets the specific or effective character format and the run over which
   205 	 * that format applies.
   206 	 */
   207 	virtual void GetCharFormat(TInt aPos,TFormatLevel aLevel,
   208 							   TTmCharFormatLayer& aFormat,TInt& aRunLength) const = 0;
   209 	/**
   210 	 * Gets the specific or effective paragraph format and the run over which
   211 	 * that format applies.
   212 	 */
   213 	virtual void GetParFormatL(TInt aPos,TFormatLevel aLevel,
   214 							   RTmParFormatLayer& aFormat,TInt& aRunLength) const = 0;
   215 
   216 	// setters
   217 
   218 	/**
   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.
   222 	 */
   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;
   227 	/**
   228 	 * Deletes aLength characters starting at aPos.
   229 	 */
   230 	virtual void DeleteTextL(TInt aPos,TInt aLength) = 0;
   231 	/**
   232 	 * Sets the base character and paragraph formats
   233 	 */
   234 	virtual void SetBaseFormatL(const TTmCharFormat& aCharFormat,const RTmParFormat& aParFormat) = 0;
   235 	/**
   236 	 * Sets specific character attributes beginning at aPos for aLength characters.
   237 	 */
   238 	virtual void SetCharFormatL(TInt aPos,TInt aLength,const TTmCharFormatLayer& aFormat) = 0;
   239 	/**
   240 	 * Sets specific paragraph attributes beginning at aPos for aLength characters.
   241 	 */
   242 	virtual void SetParFormatL(TInt aPos,TInt aLength,const RTmParFormatLayer& aFormat) = 0;
   243 	/**
   244 	 * Deletes specific character attributes beginning at aPos for aLength characters.
   245 	 */
   246 	virtual void DeleteCharFormatL(TInt aPos,TInt aLength) = 0;
   247 	/**
   248 	 * Deletes specific paragraph attributes beginning at aPos for aLength characters.
   249 	 */
   250 	virtual void DeleteParFormatL(TInt aPos,TInt aLength) = 0;
   251 
   252 	// NON-VIRTUAL FUNCTIONS
   253 	/**
   254 	 * Reads text into a writable descriptor.
   255 	 *
   256 	 * @see GetText(TInt, TPtrC) const
   257 	 */
   258 	IMPORT_C void GetText(TInt aPos, TDes& aText) const;
   259 	/**
   260 	 * Returns the interface for manipulating styles, if applicable.
   261 	 */
   262 	inline MStyleSupport* StyleSupport();
   263 	inline const MStyleSupport* StyleSupport() const;
   264 	/**
   265 	 * Returns the interface for manipulating pictures, if applicable.
   266 	 */
   267 	inline MPictureSupport* PictureSupport();
   268 	inline const MPictureSupport* PictureSupport() const;
   269 	/**
   270 	 * Returns the interface for clipboard operations, if applicable.
   271 	 */
   272 	inline MClipboardSupport* ClipboardSupport();
   273 	inline const MClipboardSupport* ClipboardSupport() const;
   274 	};
   275 
   276 // inline functions
   277 
   278 MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport()
   279 	{
   280 	return static_cast<MStyleSupport*>(Interface(KUidMUnifiedEditorStyleSupport));
   281 	}
   282 
   283 const MUnifiedEditor::MStyleSupport* MUnifiedEditor::StyleSupport() const
   284 	{
   285 	return static_cast<MStyleSupport*>(
   286 		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorStyleSupport));
   287 	}
   288 
   289 MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport()
   290 	{
   291 	return static_cast<MPictureSupport*>(Interface(KUidMUnifiedEditorPictureSupport));
   292 	}
   293 
   294 const MUnifiedEditor::MPictureSupport* MUnifiedEditor::PictureSupport() const
   295 	{
   296 	return static_cast<MPictureSupport*>(
   297 		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorPictureSupport));
   298 	}
   299 
   300 MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport()
   301 	{
   302 	return static_cast<MClipboardSupport*>(Interface(KUidMUnifiedEditorClipboardSupport));
   303 	}
   304 
   305 const MUnifiedEditor::MClipboardSupport* MUnifiedEditor::ClipboardSupport() const
   306 	{
   307 	return static_cast<MClipboardSupport*>(
   308 		const_cast<MUnifiedEditor*>(this)->Interface(KUidMUnifiedEditorClipboardSupport));
   309 	}
   310 
   311 #endif // __UNIFIED_EDITOR_H__