os/textandloc/textrendering/texthandling/inc/TXTETEXT.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1997-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 __TXTETEXT_H__
    20 #define __TXTETEXT_H__
    21 
    22 #include <e32std.h>
    23 #include <e32base.h>
    24 #include <s32std.h>
    25 
    26 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    27 #include <fldset.h>
    28 #include <txtetext_internal.h>
    29 #include <txtclipboard.h>
    30 #endif
    31 
    32 // Forward references
    33 class CParaFormatLayer;
    34 class CCharFormatLayer;
    35 class MTextFieldFactory;
    36 class CTextFieldSet;
    37 class CTextField;
    38 class TFindFieldInfo;
    39 class CInlineEditData;
    40 class MFepInlineTextFormatRetriever;
    41 class TCharFormat;
    42 class CEditableTextOptionalData;
    43 class RFs;
    44 
    45 
    46 /** 
    47 An abstract base class which defines the behaviour common to all editable 
    48 text classes.
    49 
    50 It provides no storage for text or text formatting, so it is not directly 
    51 usable. It defines protocols for editing the contents of a text object and 
    52 for extracting format data from a text object which supports formatting.
    53 
    54 Note: when specifying a position in a text object (the document position), 
    55 zero is before the first character in the document. If the document contains 
    56 n characters, position n is after the last character. Valid document positions 
    57 are therefore between zero and the length of the document, inclusive. Many 
    58 editable text functions raise a panic if a specified document position is 
    59 invalid.
    60 
    61 Note also that the functions which implement support for front-end-processor 
    62 inline editing are intended for internal use only by Symbian. 
    63 @publishedAll
    64 @released
    65 */
    66 class CEditableText : public CBase
    67 	{
    68 public:
    69 	IMPORT_C ~CEditableText();
    70 	IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
    71 	IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId);
    72 
    73 	// virtual persistence functions
    74 	virtual void ExternalizeL(RWriteStream& aStream) const;
    75 	virtual void InternalizeL(RReadStream& aStream);
    76 	
    77 	/** Stores the text components, e.g. fields, pictures and formatting to the 
    78 	stream store specified. Does not store the text content.
    79 	
    80 	@param aStore Stream store to which the text components are written. 
    81 	@param aMap A store map. This binds the address of text components to the 
    82 	stream ID of aStore. This is needed to support deferred loading of 
    83 	pictures in rich text. */
    84 	virtual void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap) const = 0;
    85 	
    86 	/** Restores the text components, e.g. fields, pictures and formatting from 
    87 	the stream store. Does not restore the text content.
    88 	
    89 	@param aStore The stream store from which the text components are restored. */
    90 	virtual void RestoreComponentsL(const CStreamStore& aStore) = 0;
    91 
    92 	// modifier functions
    93 	
    94 	/** Deletes the text content and components from the text object, leaving 
    95 	the single end-of-text paragraph delimiter. */
    96 	virtual void Reset() = 0;
    97 	
    98 	/**  Inserts a single character or a descriptor into the text object at a
    99 	specified document position.
   100 	
   101 	@param aInsertPos  A valid document position at which to insert the
   102 	            character or descriptor.
   103 	@param  aChar  The character to insert. */
   104 	virtual void InsertL(TInt aInsertPos,const TChar& aChar) = 0;
   105 
   106 	/**  Inserts a single character or a descriptor into the text object at a
   107 	specified document position.
   108 	
   109 	@param aInsertPos  A valid document position at which to insert the
   110 	            character or descriptor.
   111 	@param  aBuf  The descriptor to insert.*/
   112 	virtual void InsertL(TInt aInsertPos,const TDesC& aBuf) = 0;
   113 	
   114  	/** Deletes one or more characters beginning at (and including) the 
   115  	character at the specified document position.
   116 	
   117 	@param aPos The document position from which to delete. 
   118 	@param aLength The number of characters to delete. 
   119 	@return Indicates whether or not two paragraphs have been merged as a 
   120 	result of the delete, so that the resulting paragraph needs to be 
   121 	reformatted. This value is only relevant to rich text, so for plain and 
   122 	global text implementations, the function always returns EFalse. */
   123 	virtual TBool DeleteL(TInt aPos,TInt aLength) = 0;
   124 
   125 	// interrogation functions
   126 	
   127 	/**  Gets a read-only pointer descriptor to a portion of the text.
   128 	
   129 	@param aStartPos A valid document position from which to read.
   130 	@param aLength If specified, the number of characters to read,inclusive of 
   131 	the character at position aStartPos. If not specified, the read continues
   132 	to the end of the document, or the end of the segment if using segmented storage.
   133 	@return  Read-only pointer descriptor to a portion of the text. */ 
   134  	virtual TPtrC Read(TInt aStartPos) const = 0;
   135 
   136 	/** Gets a read-only pointer descriptor to a portion of the text.
   137 	
   138 	@param aStartPos A valid document position from which to read. 
   139 	@param aLength If specified, the number of characters to read, inclusive of 
   140 	the character at position aStartPos. If not specified, the read continues 
   141 	to the end of the document, or the end of the segment if using segmented 
   142 	storage. 
   143 	@return Read-only pointer descriptor to a portion of the text. */
   144 	virtual TPtrC Read(TInt aStartPos,TInt aLength) const = 0;
   145 	
   146 	/** Copies a portion of the text into a descriptor.
   147 	
   148 	Starts at the position specified and continues to the end of the document. 
   149 	A length may optionally be specified.
   150 	
   151 	@param aBuf Buffer which on return contains the extracted text.
   152 	@param aPos The document position from which to copy. Must be a valid 
   153 	position, or a panic occurs.
   154 	@param aLength If specified, the number of characters to copy. */ 
   155  	virtual void Extract(TDes& aBuf,TInt aPos=0) const = 0;
   156 
   157 	/** Copies a portion of the text into a descriptor. Starts at the position 
   158 	specified and continues to the end of the document. A length may optionally 
   159 	be specified.
   160 	
   161 	@param aBuf Buffer which on return contains the extracted text. 
   162 	@param aPos The document position from which to copy. Must be a valid 
   163 	position, or a panic occurs. 
   164 	@param aLength If specified, the number of characters to copy. */
   165 	virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const = 0;
   166 
   167 	// copy and paste
   168 	/** Copies a portion of the text to the clipboard.
   169 	
   170 	@param aStore The clipboard's store (see class CClipboard). 
   171 	@param aDictionary The clipboard's stream dictionary (see class CClipboard). 
   172 	@param aPos A valid document position from which to begin copying. 
   173 	@param aLength The number of characters to copy. */
   174 	virtual void CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const = 0;
   175 	
   176 	/** Pastes the contents of the clipboard into the text object at the 
   177 	specified document position.
   178 	
   179 	@param aStore The clipboard's store (see class CClipboard). 
   180 	@param aDictionary The clipboard's stream dictionary (see class CClipboard). 
   181 	@param aPos A valid document position at which to paste the text. 
   182 	@return The number of characters pasted. */
   183 	virtual TInt PasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDictionary,TInt aPos) = 0;
   184 
   185 	// utility functions
   186 	 
   187 	/** Returns a count of the number of words in the document.
   188 	
   189 	@return The number of words in the document */
   190 	virtual TInt WordCount() const = 0;
   191 	
   192 	/** Returns a count of the number of paragraphs in the document.
   193 	
   194 	@return The number of paragraphs in the document. Notes: The end-of-text 
   195 	paragraph delimiter at the end of every document means this function 
   196 	always returns a count of at least one. */
   197 	virtual TInt ParagraphCount() const = 0;
   198 	 
   199 	/** Returns a count of the number of characters in the document, 
   200 	excluding the end-of-text paragraph delimiter.
   201 	
   202 	@return The number of characters in the document. */
   203 	virtual TInt DocumentLength() const = 0;
   204 	
   205 	/** Updates a document position to the start of the paragraph.
   206 	
   207 	@param aPos Initially specifies a valid document position. On return, set 
   208 	to the document position of the first character in the paragraph. 
   209 	@return The number of characters skipped in scanning to the start of the 
   210 	paragraph. */
   211 	virtual TInt ToParagraphStart(TInt& aPos) const = 0;
   212 	inline TBool HasChanged() const;
   213 	
   214 	/** Returns the start position and length of the word that contains the 
   215 	specified document position.
   216 	
   217 	@param aCurrentPos A valid document position. 
   218 	@param aStartPos On return, the document position of the first character in 
   219 	the word containing document position aCurrentPos. 
   220 	@param aLength On return, the length of the word containing document 
   221 	position aCurrentPos. Does not include the trailing word delimiter 
   222 	character. 
   223 	@param aPictureIsDelimiter Specifies whether picture characters should be 
   224 	considered to be word delimiters. For example, this value might be EFalse 
   225 	when navigating a document, but ETrue when carrying out spell checking. 
   226 	@param aPunctuationIsDelimiter Specifies whether puncutation characters 
   227 	should be considered to be word delimiters. */
   228 	virtual void GetWordInfo(TInt aCurrentPos,TInt& aStartPos,TInt& aLength,
   229 							 TBool aPictureIsDelimiter,TBool aPunctuationIsDelimiter) const = 0;
   230 
   231 	IMPORT_C virtual TInt ScanWords(TInt& aPos,TUint& aScanMask) const;
   232 	IMPORT_C virtual TInt ScanParas(TInt& aPos,TUint& aScanMask) const;
   233 	IMPORT_C virtual void SetHasChanged(TBool aHasChanged);
   234 
   235 	// Internal to Symbian - support for front-end-processor inline editing
   236 	IMPORT_C void StartFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aInitialInlineText,TInt aPositionOfInlineTextInDocument,TInt aNumberOfCharactersToHide,MFepInlineTextFormatRetriever& aInlineTextFormatRetriever);
   237 	IMPORT_C void UpdateFepInlineTextL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aNewInlineText);
   238 	IMPORT_C void CommitFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument);
   239 	IMPORT_C void CancelFepInlineEdit(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument);
   240 	
   241 	IMPORT_C virtual void ExtendedInterface(TAny*& aInterface, TUid aInterfaceId);
   242 
   243 	IMPORT_C TInt GetPositionOfInlineTextInDocument() const;
   244 	IMPORT_C TInt GetLengthOfInlineText() const;
   245 
   246 	/** Storage type */
   247 	enum TDocumentStorage
   248 		{
   249 		 /** Storage uses a flat buffer (CBufFlat). */
   250 		EFlatStorage, 
   251 		/** Storage uses a segmented buffer (CBufSeg). */
   252 		ESegmentedStorage
   253 		};
   254 		
   255 	/** Miscellaneous constants. */
   256  	enum 
   257 		{
   258 		/** Granularity of the buffer, default 256 characters. */
   259 		EDefaultTextGranularity = 256
   260 		};
   261 
   262 	/*
   263 	Useful Unicode character definitions.
   264 	ETEXT uses standard Unicode to store its text. In particular 0x2029 and 0x2028 are used
   265 	as paragraph separator and forced line break respectively.
   266 	*/
   267 	enum
   268 		{								// Unicode name, etc.
   269 		/** Tab stop. */
   270 		ETabCharacter = 0x0009,			// horizontal tabulation
   271 		/** New page. */
   272 		EPageBreak = 0x000C,			// form feed
   273 		/** Visible space character. */
   274 		ESpace = 0x0020,				// space
   275 		EApostrophe = 0x0027,			// apostrophe
   276 		EHyphenMinus = 0x002D,			// hyphen-minus; generally used for hyphen, but see 0x2010
   277 		/** A hard (non-breaking) space. */
   278 		ENonBreakingSpace = 0x00A0,		// no-break space
   279 		/** A soft hyphen (ensures that a hyphen followed by a new line will be
   280 		inserted at that point should a line break be required anywhere within
   281 		the word).
   282 		 */
   283 		EPotentialHyphen = 0x00AD,		// soft hyphen
   284 		EHyphen = 0x2010,				// hyphen; intended as an unambiguous hyphen codepoint
   285 		/** A hard (non-breaking) hyphen. */
   286 		ENonBreakingHyphen = 0x2011,	// non-breaking hyphen
   287 		ELeftSingleQuote = 0x2018,		// left single quotation mark
   288 		ERightSingleQuote = 0x2019,		// right single quotation mark
   289 		ELeftDoubleQuote = 0x201C,		// left double quotation mark
   290 		ERightDoubleQuote = 0x201D,		// right double quotation mark
   291 		EBullet = 0x2022,				// bullet
   292 		EEllipsis = 0x2026,				// horizontal ellipsis
   293 		/** Forced line break. */
   294 		ELineBreak = 0x2028,			// line separator
   295 		/** Paragraph delimiter. */
   296 		EParagraphDelimiter = 0x2029,	// paragraph separator
   297 		/** Represents a picture inserted into the text object. */
   298 		EPictureCharacter = 0xFFFC,		// object replacement character
   299 		EZeroWidthNoBreakSpace = 0xFEFF,// zero-width no-break space
   300 		EByteOrderMark = 0xFEFF,		// byte order mark; SAME AS zero-width no-break space
   301 		EReversedByteOrderMark = 0xFFFE	// not a character; evidence of endianness opposite to that of platform
   302 		};
   303 
   304 protected:
   305 	// support for front-end-processor inline-editing
   306 	IMPORT_C void OverrideFormatOfInlineTextIfApplicable(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos) const;
   307 
   308 	TBool iHasChanged;
   309 
   310 private:
   311 	void SetAndTransferOwnershipOfInlineEditDataL(CInlineEditData* aInlineEditData);
   312 	CInlineEditData* InlineEditData() const;
   313 	void DeleteInlineEditDataAndSetToNull();
   314 	TBool DeleteWithoutDestroyingFormatL(TInt aPos, TInt aLength);
   315 
   316 	CEditableTextOptionalData* iOptionalData;
   317 	};
   318 
   319 
   320 // Information relating to the number of components owned by an editable text instance.
   321 
   322 /** 
   323 Provides information about the number of components owned by an editable 
   324 text object. 
   325 
   326 Components are fields and (rich text only), pictures and styles.
   327 
   328 An instance of this class is returned by CPlainText::ComponentInfo() and by 
   329 CRichText::ComponentInfo(). 
   330 @publishedAll
   331 @released
   332 */
   333 class TEtextComponentInfo
   334 	{
   335 public:
   336 	IMPORT_C TEtextComponentInfo();
   337 	IMPORT_C TEtextComponentInfo(TInt aFieldCount,TInt aPictureCount,TInt aStyleCount);
   338 public:
   339 	/** The number of fields in the text object. */
   340 	TInt iFieldCount;
   341 	/** The number of pictures in the text object (rich text only). */
   342 	TInt iPictureCount;
   343 	/** The number of styles owned or referenced by the text object (rich text only). */
   344 	TInt iStyleCount;
   345 	};
   346 
   347 /** 
   348 Page table.
   349 
   350 This is an array of integers; each integer represents the number or characters 
   351 on a page. 
   352 @publishedAll
   353 @released
   354 */
   355 typedef CArrayFix<TInt> TPageTable;
   356 
   357 /** 
   358 Stores and manipulates plain text. 
   359 
   360 Plain text cannot be displayed, so this class provides no support for formatting. 
   361 It is purely an in-memory buffer for text, and provides services that act 
   362 upon it. These services include the following: import from and export to streams, 
   363 optionally translating between Unicode and other encodings; reading and writing 
   364 of field data; extraction of text; finding word and paragraph boundaries.
   365 
   366 The type and size of in-memory buffer can be specified upon object construction. 
   367 However, if no specification is provided a buffer is provided with default 
   368 settings. There are two types of storage buffer: segmented buffers and flat 
   369 buffers. The default buffer for plain text is segmented (CBufSeg). This is 
   370 most efficient when a large quantity of text is to be stored, or will have 
   371 a large dynamic range. A flat buffer (CBufFlat) is most appropriate for storing 
   372 small quantities of text of bounded length. For most uses, however, a segmented 
   373 buffer is sufficient. 
   374 @publishedAll
   375 @released
   376 */
   377 class CPlainText: public CEditableText
   378 	{
   379 public:
   380 	/** Line delimiter translation. */
   381 	enum TTextOrganisation
   382 		{
   383 		 
   384 		/** When importing text from a text file, all line feeds are 
   385 		converted into paragraph delimiters.
   386 		
   387 		When exporting text to a text file, lines do not wrap and paragraph 
   388 		delimiters are converted into CR/LF pairs. */
   389 		EOrganiseByParagraph,
   390 		/** When importing text from a text file, a single line feed or a 
   391 		line feed followed by a carriage return is converted into a space 
   392 		character. A line feed which is followed by another line feed is 
   393 		converted into a CEditableText::EParagraphDelimiter.
   394 		
   395 		When exporting text to a text file, lines wrap at the specified wrap 
   396 		width and paragraph delimiters are converted into CR/LFs pairs. */
   397 		EOrganiseByLine
   398 		};
   399 
   400 	/**  Scan mask values. */ 
   401 	enum
   402 		{
   403 		/** Scan direction is backwards. The default is forwards. */
   404 		EScanBackwards = 0x01,
   405 		/** If the current document position is a word or paragraph boundary, no
   406 		scan occurs.*/
   407 		EScanStayIfBoundary = 0x02,
   408 		/** Scan to the first character in the word or paragraph. */
   409 		EScanToUnitStart = 0x04,
   410 		/** Scan to the last character in the word or paragraph. */
   411 		EScanToUnitEnd = 0x08,
   412 		/** Treat adjacent word or paragraph delimiters as a single delimiter.
   413 		Required when performing a word count, for example.
   414 		 */
   415 		EScanJoinDelimiters = 0x10,
   416 		/** Picture characters are considered to be word delimiters. */
   417 		EScanPictureIsDelimiter = 0x20,
   418 		/** Punctuation characters, except hyphens and apostrophes, are considered
   419 		to be word delimiters. */
   420 		EScanPunctuationIsDelimiter = 0x40
   421 		};
   422 
   423 	
   424 	/** Used in text scanning functions to indicate the end of the document 
   425 	has been passed. */
   426 	enum TScanDataEnd
   427 		{
   428 		/** Indicates that a scan has passed the end of text paragraph delimiter. */
   429 		EScanEndOfData = -1
   430 		};
   431 
   432 	class TImportExportParam
   433 	/** Parameters for importing or exporting text using 
   434 	CPlainText::ImportTextL() or CPlainText::ExportTextL(). */
   435 		{
   436 		public:
   437 		TImportExportParam():
   438 			iOrganisation(EOrganiseByParagraph),
   439 			iMaxOutputChars(KMaxTInt),
   440 			iMaxInputChars(KMaxTInt),
   441 			iMaxLineLength(KMaxTInt),
   442 			iOutputInternal(FALSE),
   443 			iInputInternal(FALSE),
   444 			iForeignEncoding(0),
   445 			iGuessForeignEncoding(FALSE),
   446 			iFileSession(NULL),
   447 			iReserved(0)
   448 		/** Default constructor. All member data is assigned default values. 
   449 		For details, see the member data. */
   450 			{
   451 			}
   452 
   453 		/** Controls how line delimiters are translated. By default, 
   454 		EOrganiseByParagraph.
   455 		
   456 		@see CPlainText::TTextOrganisation */
   457 		TTextOrganisation iOrganisation;
   458 		/** The maximum number of characters to write to the stream (when 
   459 		exporting) or to write to the text object (when importing). By default, 
   460 		KMaxTInt. */
   461 		TInt iMaxOutputChars;
   462 		/** The maximum number of characters to read from the stream (when 
   463 		importing) or to read from the text object (when exporting). By 
   464 		default, KMaxTInt. */
   465 		TInt iMaxInputChars;
   466 		/** The wrap width as a number of characters. 
   467 		
   468 		Only relevant when exporting by line, (iOrganisation is 
   469 		CPlainText::EOrganiseByLine). Not used in CPlainText::ImportTextL(). 
   470 		By default, KMaxTInt. */
   471 		TInt iMaxLineLength;  // maximum line length when exporting text
   472 		/** If ETrue, output is in internal format, so is written according to 
   473 		native endianness. Used in CPlainText::ExportTextL(). By default, 
   474 		EFalse. */
   475 		TBool iOutputInternal; 
   476 		/** If ETrue, input is in internal format, so is read according to 
   477 		native endianness. Used in CPlainText::ImportTextL(). By default, 
   478 		EFalse. */
   479 		TBool iInputInternal;	
   480 		/** The identifier of the foreign character set encoding to be used 
   481 		to convert from or to. 
   482 
   483 		Not used if iGuessForeignEncoding is true. If conversion to/from 
   484 		iForeignEncoding is not available on the phone, the function leaves 
   485 		with KErrNotSupported. By default, zero. */
   486 		TUint iForeignEncoding;			
   487 		/** If ETrue, an attempt is made to guess the encoding of the foreign 
   488 		text being imported before converting it into Unicode. Used in 
   489 		CPlainText::ImportTextL(). If EFalse, the value specified in 
   490 		iForeignEncoding (if any) is used. If none of the available character 
   491 		conversion plug-ins on the phone return a confidence level greater 
   492 		than 50%, CPlainText::ImportTextL() leaves with KErrNotSupported. 
   493 		By default, false. */
   494 		TBool iGuessForeignEncoding;		
   495 		/** If non-null, a connected file server session used to load character 
   496 		conversion data. Only relevant if the text needs to be converted to or 
   497 		from Unicode. By default, null. */
   498 		RFs* iFileSession;
   499 		TUint iReserved;
   500 		};
   501 
   502  	class TImportExportResult
   503 	/** Results of importing or exporting text using CPlainText::ImportTextL() 
   504 	or CPlainText::ExportTextL(). */
   505 		{
   506 		public:
   507 		TImportExportResult():
   508 			iOutputChars(0),
   509 			iInputChars(0),
   510 			iForeignEncoding(0),
   511 			iReserved(0)
   512 		/** Default constructor. All member data is initialised to zero. */
   513 			{
   514 			}
   515 
   516 		/** The number of characters written to the stream (when exporting) or 
   517 		written to this text object (when importing). */
   518 		TInt iOutputChars;
   519 		/** The number of characters read from the stream (when importing) or 
   520 		read from this text object (when exporting). */
   521 		TInt iInputChars;
   522 		/** The identifier for the character set encoding selected when 
   523 		importing text whose encoding is guessed (iGuessForeignEncoding was 
   524 		true). */
   525 		TUint iForeignEncoding;				// foreign encoding actually used; useful if the encoding was guessed
   526 		TUint iReserved;		
   527 		};
   528 			   
   529 	IMPORT_C static CPlainText* NewL(TDocumentStorage aStorage = ESegmentedStorage,
   530 									 TInt aDefaultTextGranularity = EDefaultTextGranularity);
   531 	IMPORT_C static CPlainText* NewL(const CStreamStore& aStore,TStreamId aStreamId,
   532 									 MTextFieldFactory* aFieldFactory = NULL,
   533 									 TDocumentStorage aStorage = ESegmentedStorage);
   534 	IMPORT_C virtual ~CPlainText();
   535 
   536 	// primary persistence functions
   537 	IMPORT_C virtual void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap) const;
   538 	IMPORT_C virtual void RestoreComponentsL(const CStreamStore& aStore);
   539 	IMPORT_C virtual void ExternalizeL(RWriteStream& aStream) const;
   540 	IMPORT_C virtual void InternalizeL(RReadStream& aStream);
   541 
   542 	// secondary persistence functions
   543 	IMPORT_C void ExternalizePlainTextL(RWriteStream& aStream) const;
   544 	IMPORT_C void InternalizePlainTextL(RReadStream& aStream);
   545 	IMPORT_C void ExternalizePlainTextNoLengthCountL(RWriteStream& aStream) const; // Deprecated
   546 	IMPORT_C void InternalizePlainTextL(RReadStream& aStream,TInt aLength); // Deprecated
   547 
   548 	// import and export text
   549 	IMPORT_C void ImportTextL(TInt aPos,RReadStream& aInput,TTextOrganisation aTextOrganisation,
   550 							  TInt aMaxOutputChars = KMaxTInt,TInt aMaxInputChars = KMaxTInt,
   551 							  TInt* aOutputChars = NULL,TInt* aInputChars = NULL);
   552 	IMPORT_C void ExportTextL(TInt aPos,RWriteStream& aOutput,TTextOrganisation aTextOrganisation,
   553 							  TInt aMaxOutputChars = KMaxTInt,TInt aMaxInputChars = KMaxTInt,
   554 							  TInt aMaxLineLength = KMaxTInt,
   555 							  TInt* aOutputChars = NULL,TInt* aInputChars = NULL) const;
   556 	IMPORT_C virtual TInt ImportTextFileL(TInt aPos,const TDes& aFileName,TTextOrganisation aTextOrganisation);
   557 	IMPORT_C virtual void ExportAsTextL(const TDes& aFileName,TTextOrganisation aTextOrganisation,
   558 										TInt aMaxLineLength) const;
   559 
   560 	// import and export text AND optionally translate from or to a non-Unicode encoding
   561 	IMPORT_C void ImportTextL(TInt aPos,RReadStream& aInput,
   562 							  const TImportExportParam& aParam,TImportExportResult& aResult);
   563 	IMPORT_C void ExportTextL(TInt aPos,RWriteStream& aOutput,
   564 							  const TImportExportParam& aParam,TImportExportResult& aResult) const;
   565 
   566 	// read and write field data
   567 	IMPORT_C void StoreFieldComponentsL(CStreamStore& aStore,CStoreMap& aMap) const;
   568 	IMPORT_C void RestoreFieldComponentsL(const CStreamStore& aStore);
   569 	IMPORT_C void ExternalizeFieldDataL(RWriteStream& aStream) const;
   570 	IMPORT_C void InternalizeFieldDataL(RReadStream& aStream);
   571 
   572 	// modifier functions
   573 	IMPORT_C virtual void Reset();
   574 	IMPORT_C virtual void InsertL(TInt aPos,const TChar& aChar);
   575 	IMPORT_C virtual void InsertL(TInt aPos,const TDesC& aBuf);
   576 	IMPORT_C virtual TBool DeleteL(TInt aPos,TInt aLength);
   577 
   578 	// interrogation functions
   579 	IMPORT_C virtual TPtrC Read(TInt aStartPos) const;
   580 	IMPORT_C virtual TPtrC Read(TInt aStartPos,TInt aLength) const;
   581 	IMPORT_C virtual void Extract(TDes& aBuf,TInt aPos=0) const;
   582 	IMPORT_C virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const;
   583 
   584 	// Flags for ExtractSelectively
   585 	enum
   586 		{
   587 		EExtractAll = 0,	// extract all characters
   588 		EExtractVisible = 1,	// discard control characters and soft hyphens; change par and line separators to spaces
   589 		EExcludeInlineEditedText = 2 // discard the inline text
   590 		};
   591 	IMPORT_C void ExtractSelectively(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags);
   592 
   593 	// copy and paste
   594 	IMPORT_C virtual void CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const;
   595 	IMPORT_C virtual TInt PasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDictionary,TInt aPos);
   596 
   597 	// utility functions
   598 	IMPORT_C void SetPageTable(TPageTable* aPageTable);
   599 	IMPORT_C TInt PageContainingPos(TInt aPos) const;
   600 	IMPORT_C virtual TInt DocumentLength() const;
   601  	IMPORT_C virtual TInt WordCount() const;
   602 	IMPORT_C virtual TInt ParagraphCount() const;
   603 	IMPORT_C virtual TInt ToParagraphStart(TInt& aPos) const;
   604 	IMPORT_C virtual TInt CharPosOfParagraph(TInt& aLength,TInt aParaOffset) const;
   605 	IMPORT_C virtual TInt ParagraphNumberForPos(TInt& aPos) const;
   606 	IMPORT_C virtual void GetWordInfo(TInt aCurrentPos,TInt& aStartPos,TInt& aLength,
   607 						TBool aPictureIsDelimiter,TBool aPunctuationIsDelimiter) const;
   608 	IMPORT_C virtual TInt ScanWords(TInt& aPos,TUint& aScanMask) const;
   609 	IMPORT_C virtual TInt ScanParas(TInt& aPos,TUint& aScanMask) const;
   610 	IMPORT_C virtual TEtextComponentInfo ComponentInfo() const;
   611 	//
   612 	// Field functions
   613 	IMPORT_C void SetFieldFactory(MTextFieldFactory* aFactory);
   614 	IMPORT_C const MTextFieldFactory* FieldFactory() const;
   615 	IMPORT_C CTextField* NewTextFieldL(TUid aFieldType) const;
   616 	IMPORT_C void InsertFieldL(TInt aPos,CTextField* aField,TUid aFieldType); 
   617 	IMPORT_C virtual void UpdateFieldL(TInt aPos); 
   618 	IMPORT_C void UpdateAllFieldsL(); 
   619 	IMPORT_C TInt FieldCount() const;
   620 	IMPORT_C const CTextField* TextField(TInt aPos) const;
   621 	IMPORT_C TBool FindFields(TInt aPos) const; 
   622 	IMPORT_C TBool FindFields(TFindFieldInfo& aInfo,TInt aPos,TInt aRange=0) const;
   623 	IMPORT_C TBool RemoveField(TInt aPos);  
   624 	IMPORT_C TBool ConvertFieldToText(TInt aPos); 
   625 	IMPORT_C void ConvertAllFieldsToText();
   626 	
   627 	IMPORT_C void ExtendedInterface(TAny*& aInterface, TUid aInterfaceId); // from CEditableText
   628 
   629 protected:
   630 	IMPORT_C CPlainText();
   631 	IMPORT_C void ConstructL(TDocumentStorage aStorage = ESegmentedStorage,
   632 							 TInt aDefaultTextGranularity = EDefaultTextGranularity);
   633 	IMPORT_C void ConstructL(const CStreamStore& aStore,TStreamId aStreamId,MTextFieldFactory* aFieldFactory,
   634 							 TDocumentStorage aStorage = ESegmentedStorage);
   635 	IMPORT_C void DoConstructL(TDocumentStorage aStorage,TInt aDefaultTextGranularity,
   636 							   MTextFieldFactory* aFieldFactory = NULL);
   637 	void DoExtract(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags = 0) const;
   638 	IMPORT_C void PtInsertL(TInt aInsertPos,const TDesC& aBuf);
   639 	IMPORT_C void DoPtInsertL(TInt aPos,const TDesC& aBuf);
   640 	IMPORT_C TBool DoPtDelete(TInt aPos,TInt aLength);
   641 	void InsertL(TInt aPos,const CPlainText* aText);
   642 	TBool Delete(TInt aPos,TInt aLength);
   643 
   644 	// streaming
   645 	IMPORT_C void DoExternalizeFieldDataL(RWriteStream& aStream) const;
   646 	IMPORT_C void DoInternalizeFieldDataL(RReadStream& aStream);
   647 	IMPORT_C void DoExternalizePlainTextL(RWriteStream& aStream) const;
   648 	IMPORT_C void DoInternalizePlainTextL(RReadStream& aStream);
   649 	TStreamId DoCopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const;
   650 	TInt DoPasteFromStoreL(const CStreamStore& aStore,TStreamId aStreamId,TInt aPos);
   651 	void CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength) const;
   652 	void PasteComponentsL(const CStreamStore& aStore,TInt aPos);
   653 	void CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength) const;
   654 
   655 	// utility functions
   656 	inline static void ConsumeAdornmentL(RReadStream& aStream);
   657 	inline static TUid UidFromStreamL(RReadStream& aStream);
   658 protected:
   659 	enum
   660 		{
   661 		EImportBufSize = 512,
   662 		EBiggestCharacterPaste=0x100000
   663 		};
   664 
   665 	enum TUnitOfText
   666 		{
   667 		EUnitIsWord,
   668 		EUnitIsParagraph
   669 		};
   670 
   671 	struct SScanData
   672 		{
   673 		TInt pos;			// current character position
   674 		TInt oldPos;		// old character position
   675 		TText* buf;			// address of data (Unicode-aware)
   676 		TInt currentSegLen; // number of characters left in segment
   677 		TInt totalBufLen;	// number of unread characters
   678 		TInt delta;			// specifies current scan direction
   679 		TUint32 scanMask;	// bitmask containing the scan settings
   680 		enum
   681 			{
   682 			EInsideUnit = 0x10000000,
   683 			EStopEnd = 0x20000000,
   684 			EStopBegin = 0x40000000,
   685 			EIsDelimiter = 0x80000000
   686 			};
   687 		};
   688 
   689 private:
   690 	CPlainText(const CPlainText& aPlainTextDoc);
   691 	CPlainText& operator=(const CPlainText& aPlainTextDoc);
   692 	TInt PasteFromStreamL(RReadStream& aStream,TInt aPos);
   693 	TInt DoPasteFromStreamL(RReadStream& aStream, TInt aPos);
   694 	void InsertEodL();
   695 	void InitScanControl(TInt& aPos,TUint& aScanMask,TUnitOfText aContext,SScanData& aScanData) const;
   696 	void InitScanData(TInt aPos,SScanData& aScanData) const;
   697 	void KillFieldSet();
   698 	TInt CountUnits(TUnitOfText aContext) const;
   699 	TInt ScanUnit(TInt& aPos,TUnitOfText aContext,SScanData& aScanData) const;
   700 	TBool TestForDelimiter(TUnitOfText aContext,SScanData& aScanData) const;
   701 	TBool GetChar(SScanData& aScanData,TChar& aChar) const;
   702 	void UpdatePageTable(TInt aPos,TInt aLength);
   703 	inline TBool FieldSetPresent() const;
   704 	void CreateFieldSetL(TInt aDocumentLength);
   705 
   706 	IMPORT_C virtual void Reserved_2();	// new
   707 
   708 	void* iReserved_1;
   709 
   710 protected:
   711 	CBufBase* iByteStore;				// handle to document storage class.
   712 	TSwizzle<CTextFieldSet> iFieldSet;  // handle to field storage class
   713 	TPageTable* iPageTable;				// may be NULL
   714 	MTextFieldFactory* iFieldFactory;  // temporary handle to field factory during restoration
   715 
   716 	__DECLARE_TEST;
   717 	};
   718 
   719 
   720 #include <txtetext.inl>
   721 
   722 #endif // __TXTETEXT_H__