1.1 --- a/epoc32/include/txtetext.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/txtetext.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,730 @@
1.4 -txtetext.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __TXTETEXT_H__
1.21 +#define __TXTETEXT_H__
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +#include <fldset.h>
1.26 +#include <s32std.h>
1.27 +
1.28 +
1.29 +// Forward references
1.30 +class CParaFormatLayer;
1.31 +class CCharFormatLayer;
1.32 +class MTextFieldFactory;
1.33 +class CTextFieldSet;
1.34 +class CTextField;
1.35 +class TFindFieldInfo;
1.36 +class CInlineEditData;
1.37 +class MFepInlineTextFormatRetriever;
1.38 +class TCharFormat;
1.39 +class CEditableTextOptionalData;
1.40 +class RFs;
1.41 +
1.42 +
1.43 +/**
1.44 +UIDs
1.45 +@internalComponent
1.46 +*/
1.47 +const TUid KPlainTextFieldDataUid = {268435555};
1.48 +const TUid KEditableTextUid = {268450334};
1.49 +const TUid KPlainTextCharacterDataUid = {268450341};
1.50 +const TUid KClipboardUidTypePlainText = {268450333};
1.51 +const TUid KUidRichText = {271013233};
1.52 +
1.53 +/**
1.54 +@internalComponent
1.55 +*/
1.56 +const TInt KMaxFieldBufferSize=0x14;
1.57 +
1.58 +/**
1.59 +An abstract base class which defines the behaviour common to all editable
1.60 +text classes.
1.61 +
1.62 +It provides no storage for text or text formatting, so it is not directly
1.63 +usable. It defines protocols for editing the contents of a text object and
1.64 +for extracting format data from a text object which supports formatting.
1.65 +
1.66 +Note: when specifying a position in a text object (the document position),
1.67 +zero is before the first character in the document. If the document contains
1.68 +n characters, position n is after the last character. Valid document positions
1.69 +are therefore between zero and the length of the document, inclusive. Many
1.70 +editable text functions raise a panic if a specified document position is
1.71 +invalid.
1.72 +
1.73 +Note also that the functions which implement support for front-end-processor
1.74 +inline editing are intended for internal use only by Symbian.
1.75 +@publishedAll
1.76 +@released
1.77 +*/
1.78 +class CEditableText : public CBase
1.79 + {
1.80 +public:
1.81 + IMPORT_C ~CEditableText();
1.82 + IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
1.83 + IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId);
1.84 +
1.85 + // virtual persistence functions
1.86 + virtual void ExternalizeL(RWriteStream& aStream) const;
1.87 + virtual void InternalizeL(RReadStream& aStream);
1.88 +
1.89 + /** Stores the text components, e.g. fields, pictures and formatting to the
1.90 + stream store specified. Does not store the text content.
1.91 +
1.92 + @param aStore Stream store to which the text components are written.
1.93 + @param aMap A store map. This binds the address of text components to the
1.94 + stream ID of aStore. This is needed to support deferred loading of
1.95 + pictures in rich text. */
1.96 + virtual void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap) const = 0;
1.97 +
1.98 + /** Restores the text components, e.g. fields, pictures and formatting from
1.99 + the stream store. Does not restore the text content.
1.100 +
1.101 + @param aStore The stream store from which the text components are restored. */
1.102 + virtual void RestoreComponentsL(const CStreamStore& aStore) = 0;
1.103 +
1.104 + // modifier functions
1.105 +
1.106 + /** Deletes the text content and components from the text object, leaving
1.107 + the single end-of-text paragraph delimiter. */
1.108 + virtual void Reset() = 0;
1.109 +
1.110 + /** Inserts a single character or a descriptor into the text object at a
1.111 + specified document position.
1.112 +
1.113 + @param aInsertPos A valid document position at which to insert the
1.114 + character or descriptor.
1.115 + @param aChar The character to insert. */
1.116 + virtual void InsertL(TInt aInsertPos,const TChar& aChar) = 0;
1.117 +
1.118 + /** Inserts a single character or a descriptor into the text object at a
1.119 + specified document position.
1.120 +
1.121 + @param aInsertPos A valid document position at which to insert the
1.122 + character or descriptor.
1.123 + @param aBuf The descriptor to insert.*/
1.124 + virtual void InsertL(TInt aInsertPos,const TDesC& aBuf) = 0;
1.125 +
1.126 + /** Deletes one or more characters beginning at (and including) the
1.127 + character at the specified document position.
1.128 +
1.129 + @param aPos The document position from which to delete.
1.130 + @param aLength The number of characters to delete.
1.131 + @return Indicates whether or not two paragraphs have been merged as a
1.132 + result of the delete, so that the resulting paragraph needs to be
1.133 + reformatted. This value is only relevant to rich text, so for plain and
1.134 + global text implementations, the function always returns EFalse. */
1.135 + virtual TBool DeleteL(TInt aPos,TInt aLength) = 0;
1.136 +
1.137 + // interrogation functions
1.138 +
1.139 + /** Gets a read-only pointer descriptor to a portion of the text.
1.140 +
1.141 + @param aStartPos A valid document position from which to read.
1.142 + @param aLength If specified, the number of characters to read,inclusive of
1.143 + the character at position aStartPos. If not specified, the read continues
1.144 + to the end of the document, or the end of the segment if using segmented storage.
1.145 + @return Read-only pointer descriptor to a portion of the text. */
1.146 + virtual TPtrC Read(TInt aStartPos) const = 0;
1.147 +
1.148 + /** Gets a read-only pointer descriptor to a portion of the text.
1.149 +
1.150 + @param aStartPos A valid document position from which to read.
1.151 + @param aLength If specified, the number of characters to read, inclusive of
1.152 + the character at position aStartPos. If not specified, the read continues
1.153 + to the end of the document, or the end of the segment if using segmented
1.154 + storage.
1.155 + @return Read-only pointer descriptor to a portion of the text. */
1.156 + virtual TPtrC Read(TInt aStartPos,TInt aLength) const = 0;
1.157 +
1.158 + /** Copies a portion of the text into a descriptor.
1.159 +
1.160 + Starts at the position specified and continues to the end of the document.
1.161 + A length may optionally be specified.
1.162 +
1.163 + @param aBuf Buffer which on return contains the extracted text.
1.164 + @param aPos The document position from which to copy. Must be a valid
1.165 + position, or a panic occurs.
1.166 + @param aLength If specified, the number of characters to copy. */
1.167 + virtual void Extract(TDes& aBuf,TInt aPos=0) const = 0;
1.168 +
1.169 + /** Copies a portion of the text into a descriptor. Starts at the position
1.170 + specified and continues to the end of the document. A length may optionally
1.171 + be specified.
1.172 +
1.173 + @param aBuf Buffer which on return contains the extracted text.
1.174 + @param aPos The document position from which to copy. Must be a valid
1.175 + position, or a panic occurs.
1.176 + @param aLength If specified, the number of characters to copy. */
1.177 + virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const = 0;
1.178 +
1.179 + // copy and paste
1.180 + /** Copies a portion of the text to the clipboard.
1.181 +
1.182 + @param aStore The clipboard's store (see class CClipboard).
1.183 + @param aDictionary The clipboard's stream dictionary (see class CClipboard).
1.184 + @param aPos A valid document position from which to begin copying.
1.185 + @param aLength The number of characters to copy. */
1.186 + virtual void CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const = 0;
1.187 +
1.188 + /** Pastes the contents of the clipboard into the text object at the
1.189 + specified document position.
1.190 +
1.191 + @param aStore The clipboard's store (see class CClipboard).
1.192 + @param aDictionary The clipboard's stream dictionary (see class CClipboard).
1.193 + @param aPos A valid document position at which to paste the text.
1.194 + @return The number of characters pasted. */
1.195 + virtual TInt PasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDictionary,TInt aPos) = 0;
1.196 +
1.197 + // utility functions
1.198 +
1.199 + /** Returns a count of the number of words in the document.
1.200 +
1.201 + @return The number of words in the document */
1.202 + virtual TInt WordCount() const = 0;
1.203 +
1.204 + /** Returns a count of the number of paragraphs in the document.
1.205 +
1.206 + @return The number of paragraphs in the document. Notes: The end-of-text
1.207 + paragraph delimiter at the end of every document means this function
1.208 + always returns a count of at least one. */
1.209 + virtual TInt ParagraphCount() const = 0;
1.210 +
1.211 + /** Returns a count of the number of characters in the document,
1.212 + excluding the end-of-text paragraph delimiter.
1.213 +
1.214 + @return The number of characters in the document. */
1.215 + virtual TInt DocumentLength() const = 0;
1.216 +
1.217 + /** Updates a document position to the start of the paragraph.
1.218 +
1.219 + @param aPos Initially specifies a valid document position. On return, set
1.220 + to the document position of the first character in the paragraph.
1.221 + @return The number of characters skipped in scanning to the start of the
1.222 + paragraph. */
1.223 + virtual TInt ToParagraphStart(TInt& aPos) const = 0;
1.224 + inline TBool HasChanged() const;
1.225 +
1.226 + /** Returns the start position and length of the word that contains the
1.227 + specified document position.
1.228 +
1.229 + @param aCurrentPos A valid document position.
1.230 + @param aStartPos On return, the document position of the first character in
1.231 + the word containing document position aCurrentPos.
1.232 + @param aLength On return, the length of the word containing document
1.233 + position aCurrentPos. Does not include the trailing word delimiter
1.234 + character.
1.235 + @param aPictureIsDelimiter Specifies whether picture characters should be
1.236 + considered to be word delimiters. For example, this value might be EFalse
1.237 + when navigating a document, but ETrue when carrying out spell checking.
1.238 + @param aPunctuationIsDelimiter Specifies whether puncutation characters
1.239 + should be considered to be word delimiters. */
1.240 + virtual void GetWordInfo(TInt aCurrentPos,TInt& aStartPos,TInt& aLength,
1.241 + TBool aPictureIsDelimiter,TBool aPunctuationIsDelimiter) const = 0;
1.242 +
1.243 + IMPORT_C virtual TInt ScanWords(TInt& aPos,TUint& aScanMask) const;
1.244 + IMPORT_C virtual TInt ScanParas(TInt& aPos,TUint& aScanMask) const;
1.245 + IMPORT_C virtual void SetHasChanged(TBool aHasChanged);
1.246 +
1.247 + // Internal to Symbian - support for front-end-processor inline editing
1.248 + IMPORT_C void StartFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aInitialInlineText,TInt aPositionOfInlineTextInDocument,TInt aNumberOfCharactersToHide,MFepInlineTextFormatRetriever& aInlineTextFormatRetriever);
1.249 + IMPORT_C void UpdateFepInlineTextL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument,const TDesC& aNewInlineText);
1.250 + IMPORT_C void CommitFepInlineEditL(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument);
1.251 + IMPORT_C void CancelFepInlineEdit(TBool& aParagraphContainingStartPositionOfInlineTextHasChangedFormat,TInt& aNumberOfCharactersSuccessfullyDeleted,TInt& aNumberOfCharactersSuccessfullyInserted,TInt& aPositionOfInsertionPointInDocument,TInt aNewPositionOfInsertionPointInDocument);
1.252 +
1.253 + IMPORT_C virtual void ExtendedInterface(TAny*& aInterface, TUid aInterfaceId);
1.254 +
1.255 + IMPORT_C TInt GetPositionOfInlineTextInDocument() const;
1.256 + IMPORT_C TInt GetLengthOfInlineText() const;
1.257 +
1.258 + /** Storage type */
1.259 + enum TDocumentStorage
1.260 + {
1.261 + /** Storage uses a flat buffer (CBufFlat). */
1.262 + EFlatStorage,
1.263 + /** Storage uses a segmented buffer (CBufSeg). */
1.264 + ESegmentedStorage
1.265 + };
1.266 +
1.267 + /** Miscellaneous constants. */
1.268 + enum
1.269 + {
1.270 + /** Granularity of the buffer, default 256 characters. */
1.271 + EDefaultTextGranularity = 256
1.272 + };
1.273 +
1.274 + /*
1.275 + Useful Unicode character definitions.
1.276 + ETEXT uses standard Unicode to store its text. In particular 0x2029 and 0x2028 are used
1.277 + as paragraph separator and forced line break respectively.
1.278 + */
1.279 + enum
1.280 + { // Unicode name, etc.
1.281 + /** Tab stop. */
1.282 + ETabCharacter = 0x0009, // horizontal tabulation
1.283 + /** New page. */
1.284 + EPageBreak = 0x000C, // form feed
1.285 + /** Visible space character. */
1.286 + ESpace = 0x0020, // space
1.287 + EApostrophe = 0x0027, // apostrophe
1.288 + EHyphenMinus = 0x002D, // hyphen-minus; generally used for hyphen, but see 0x2010
1.289 + /** A hard (non-breaking) space. */
1.290 + ENonBreakingSpace = 0x00A0, // no-break space
1.291 + /** A soft hyphen (ensures that a hyphen followed by a new line will be
1.292 + inserted at that point should a line break be required anywhere within
1.293 + the word).
1.294 + */
1.295 + EPotentialHyphen = 0x00AD, // soft hyphen
1.296 + EHyphen = 0x2010, // hyphen; intended as an unambiguous hyphen codepoint
1.297 + /** A hard (non-breaking) hyphen. */
1.298 + ENonBreakingHyphen = 0x2011, // non-breaking hyphen
1.299 + ELeftSingleQuote = 0x2018, // left single quotation mark
1.300 + ERightSingleQuote = 0x2019, // right single quotation mark
1.301 + ELeftDoubleQuote = 0x201C, // left double quotation mark
1.302 + ERightDoubleQuote = 0x201D, // right double quotation mark
1.303 + EBullet = 0x2022, // bullet
1.304 + EEllipsis = 0x2026, // horizontal ellipsis
1.305 + /** Forced line break. */
1.306 + ELineBreak = 0x2028, // line separator
1.307 + /** Paragraph delimiter. */
1.308 + EParagraphDelimiter = 0x2029, // paragraph separator
1.309 + /** Represents a picture inserted into the text object. */
1.310 + EPictureCharacter = 0xFFFC, // object replacement character
1.311 + EZeroWidthNoBreakSpace = 0xFEFF,// zero-width no-break space
1.312 + EByteOrderMark = 0xFEFF, // byte order mark; SAME AS zero-width no-break space
1.313 + EReversedByteOrderMark = 0xFFFE // not a character; evidence of endianness opposite to that of platform
1.314 + };
1.315 +
1.316 +protected:
1.317 + // support for front-end-processor inline-editing
1.318 + IMPORT_C void OverrideFormatOfInlineTextIfApplicable(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos) const;
1.319 +
1.320 + TBool iHasChanged;
1.321 +
1.322 +private:
1.323 + void SetAndTransferOwnershipOfInlineEditDataL(CInlineEditData* aInlineEditData);
1.324 + CInlineEditData* InlineEditData() const;
1.325 + void DeleteInlineEditDataAndSetToNull();
1.326 + TBool DeleteWithoutDestroyingFormatL(TInt aPos, TInt aLength);
1.327 +
1.328 + CEditableTextOptionalData* iOptionalData;
1.329 + };
1.330 +
1.331 +
1.332 +// Information relating to the number of components owned by an editable text instance.
1.333 +
1.334 +/**
1.335 +Provides information about the number of components owned by an editable
1.336 +text object.
1.337 +
1.338 +Components are fields and (rich text only), pictures and styles.
1.339 +
1.340 +An instance of this class is returned by CPlainText::ComponentInfo() and by
1.341 +CRichText::ComponentInfo().
1.342 +@publishedAll
1.343 +@released
1.344 +*/
1.345 +class TEtextComponentInfo
1.346 + {
1.347 +public:
1.348 + IMPORT_C TEtextComponentInfo();
1.349 + IMPORT_C TEtextComponentInfo(TInt aFieldCount,TInt aPictureCount,TInt aStyleCount);
1.350 +public:
1.351 + /** The number of fields in the text object. */
1.352 + TInt iFieldCount;
1.353 + /** The number of pictures in the text object (rich text only). */
1.354 + TInt iPictureCount;
1.355 + /** The number of styles owned or referenced by the text object (rich text only). */
1.356 + TInt iStyleCount;
1.357 + };
1.358 +
1.359 +/**
1.360 +Page table.
1.361 +
1.362 +This is an array of integers; each integer represents the number or characters
1.363 +on a page.
1.364 +@publishedAll
1.365 +@released
1.366 +*/
1.367 +typedef CArrayFix<TInt> TPageTable;
1.368 +
1.369 +/**
1.370 +Stores and manipulates plain text.
1.371 +
1.372 +Plain text cannot be displayed, so this class provides no support for formatting.
1.373 +It is purely an in-memory buffer for text, and provides services that act
1.374 +upon it. These services include the following: import from and export to streams,
1.375 +optionally translating between Unicode and other encodings; reading and writing
1.376 +of field data; extraction of text; finding word and paragraph boundaries.
1.377 +
1.378 +The type and size of in-memory buffer can be specified upon object construction.
1.379 +However, if no specification is provided a buffer is provided with default
1.380 +settings. There are two types of storage buffer: segmented buffers and flat
1.381 +buffers. The default buffer for plain text is segmented (CBufSeg). This is
1.382 +most efficient when a large quantity of text is to be stored, or will have
1.383 +a large dynamic range. A flat buffer (CBufFlat) is most appropriate for storing
1.384 +small quantities of text of bounded length. For most uses, however, a segmented
1.385 +buffer is sufficient.
1.386 +@publishedAll
1.387 +@released
1.388 +*/
1.389 +class CPlainText: public CEditableText
1.390 + {
1.391 +public:
1.392 + /** Line delimiter translation. */
1.393 + enum TTextOrganisation
1.394 + {
1.395 +
1.396 + /** When importing text from a text file, all line feeds are
1.397 + converted into paragraph delimiters.
1.398 +
1.399 + When exporting text to a text file, lines do not wrap and paragraph
1.400 + delimiters are converted into CR/LF pairs. */
1.401 + EOrganiseByParagraph,
1.402 + /** When importing text from a text file, a single line feed or a
1.403 + line feed followed by a carriage return is converted into a space
1.404 + character. A line feed which is followed by another line feed is
1.405 + converted into a CEditableText::EParagraphDelimiter.
1.406 +
1.407 + When exporting text to a text file, lines wrap at the specified wrap
1.408 + width and paragraph delimiters are converted into CR/LFs pairs. */
1.409 + EOrganiseByLine
1.410 + };
1.411 +
1.412 + /** Scan mask values. */
1.413 + enum
1.414 + {
1.415 + /** Scan direction is backwards. The default is forwards. */
1.416 + EScanBackwards = 0x01,
1.417 + /** If the current document position is a word or paragraph boundary, no
1.418 + scan occurs.*/
1.419 + EScanStayIfBoundary = 0x02,
1.420 + /** Scan to the first character in the word or paragraph. */
1.421 + EScanToUnitStart = 0x04,
1.422 + /** Scan to the last character in the word or paragraph. */
1.423 + EScanToUnitEnd = 0x08,
1.424 + /** Treat adjacent word or paragraph delimiters as a single delimiter.
1.425 + Required when performing a word count, for example.
1.426 + */
1.427 + EScanJoinDelimiters = 0x10,
1.428 + /** Picture characters are considered to be word delimiters. */
1.429 + EScanPictureIsDelimiter = 0x20,
1.430 + /** Punctuation characters, except hyphens and apostrophes, are considered
1.431 + to be word delimiters. */
1.432 + EScanPunctuationIsDelimiter = 0x40
1.433 + };
1.434 +
1.435 +
1.436 + /** Used in text scanning functions to indicate the end of the document
1.437 + has been passed. */
1.438 + enum TScanDataEnd
1.439 + {
1.440 + /** Indicates that a scan has passed the end of text paragraph delimiter. */
1.441 + EScanEndOfData = -1
1.442 + };
1.443 +
1.444 + class TImportExportParam
1.445 + /** Parameters for importing or exporting text using
1.446 + CPlainText::ImportTextL() or CPlainText::ExportTextL(). */
1.447 + {
1.448 + public:
1.449 + TImportExportParam():
1.450 + iOrganisation(EOrganiseByParagraph),
1.451 + iMaxOutputChars(KMaxTInt),
1.452 + iMaxInputChars(KMaxTInt),
1.453 + iMaxLineLength(KMaxTInt),
1.454 + iOutputInternal(FALSE),
1.455 + iInputInternal(FALSE),
1.456 + iForeignEncoding(0),
1.457 + iGuessForeignEncoding(FALSE),
1.458 + iFileSession(NULL),
1.459 + iReserved(0)
1.460 + /** Default constructor. All member data is assigned default values.
1.461 + For details, see the member data. */
1.462 + {
1.463 + }
1.464 +
1.465 + /** Controls how line delimiters are translated. By default,
1.466 + EOrganiseByParagraph.
1.467 +
1.468 + @see CPlainText::TTextOrganisation */
1.469 + TTextOrganisation iOrganisation;
1.470 + /** The maximum number of characters to write to the stream (when
1.471 + exporting) or to write to the text object (when importing). By default,
1.472 + KMaxTInt. */
1.473 + TInt iMaxOutputChars;
1.474 + /** The maximum number of characters to read from the stream (when
1.475 + importing) or to read from the text object (when exporting). By
1.476 + default, KMaxTInt. */
1.477 + TInt iMaxInputChars;
1.478 + /** The wrap width as a number of characters.
1.479 +
1.480 + Only relevant when exporting by line, (iOrganisation is
1.481 + CPlainText::EOrganiseByLine). Not used in CPlainText::ImportTextL().
1.482 + By default, KMaxTInt. */
1.483 + TInt iMaxLineLength; // maximum line length when exporting text
1.484 + /** If ETrue, output is in internal format, so is written according to
1.485 + native endianness. Used in CPlainText::ExportTextL(). By default,
1.486 + EFalse. */
1.487 + TBool iOutputInternal;
1.488 + /** If ETrue, input is in internal format, so is read according to
1.489 + native endianness. Used in CPlainText::ImportTextL(). By default,
1.490 + EFalse. */
1.491 + TBool iInputInternal;
1.492 + /** The identifier of the foreign character set encoding to be used
1.493 + to convert from or to.
1.494 +
1.495 + Not used if iGuessForeignEncoding is true. If conversion to/from
1.496 + iForeignEncoding is not available on the phone, the function leaves
1.497 + with KErrNotSupported. By default, zero. */
1.498 + TUint iForeignEncoding;
1.499 + /** If ETrue, an attempt is made to guess the encoding of the foreign
1.500 + text being imported before converting it into Unicode. Used in
1.501 + CPlainText::ImportTextL(). If EFalse, the value specified in
1.502 + iForeignEncoding (if any) is used. If none of the available character
1.503 + conversion plug-ins on the phone return a confidence level greater
1.504 + than 50%, CPlainText::ImportTextL() leaves with KErrNotSupported.
1.505 + By default, false. */
1.506 + TBool iGuessForeignEncoding;
1.507 + /** If non-null, a connected file server session used to load character
1.508 + conversion data. Only relevant if the text needs to be converted to or
1.509 + from Unicode. By default, null. */
1.510 + RFs* iFileSession;
1.511 + TUint iReserved;
1.512 + };
1.513 +
1.514 + class TImportExportResult
1.515 + /** Results of importing or exporting text using CPlainText::ImportTextL()
1.516 + or CPlainText::ExportTextL(). */
1.517 + {
1.518 + public:
1.519 + TImportExportResult():
1.520 + iOutputChars(0),
1.521 + iInputChars(0),
1.522 + iForeignEncoding(0),
1.523 + iReserved(0)
1.524 + /** Default constructor. All member data is initialised to zero. */
1.525 + {
1.526 + }
1.527 +
1.528 + /** The number of characters written to the stream (when exporting) or
1.529 + written to this text object (when importing). */
1.530 + TInt iOutputChars;
1.531 + /** The number of characters read from the stream (when importing) or
1.532 + read from this text object (when exporting). */
1.533 + TInt iInputChars;
1.534 + /** The identifier for the character set encoding selected when
1.535 + importing text whose encoding is guessed (iGuessForeignEncoding was
1.536 + true). */
1.537 + TUint iForeignEncoding; // foreign encoding actually used; useful if the encoding was guessed
1.538 + TUint iReserved;
1.539 + };
1.540 +
1.541 + IMPORT_C static CPlainText* NewL(TDocumentStorage aStorage = ESegmentedStorage,
1.542 + TInt aDefaultTextGranularity = EDefaultTextGranularity);
1.543 + IMPORT_C static CPlainText* NewL(const CStreamStore& aStore,TStreamId aStreamId,
1.544 + MTextFieldFactory* aFieldFactory = NULL,
1.545 + TDocumentStorage aStorage = ESegmentedStorage);
1.546 + IMPORT_C virtual ~CPlainText();
1.547 +
1.548 + // primary persistence functions
1.549 + IMPORT_C virtual void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap) const;
1.550 + IMPORT_C virtual void RestoreComponentsL(const CStreamStore& aStore);
1.551 + IMPORT_C virtual void ExternalizeL(RWriteStream& aStream) const;
1.552 + IMPORT_C virtual void InternalizeL(RReadStream& aStream);
1.553 +
1.554 + // secondary persistence functions
1.555 + IMPORT_C void ExternalizePlainTextL(RWriteStream& aStream) const;
1.556 + IMPORT_C void InternalizePlainTextL(RReadStream& aStream);
1.557 + IMPORT_C void ExternalizePlainTextNoLengthCountL(RWriteStream& aStream) const; // Deprecated
1.558 + IMPORT_C void InternalizePlainTextL(RReadStream& aStream,TInt aLength); // Deprecated
1.559 +
1.560 + // import and export text
1.561 + IMPORT_C void ImportTextL(TInt aPos,RReadStream& aInput,TTextOrganisation aTextOrganisation,
1.562 + TInt aMaxOutputChars = KMaxTInt,TInt aMaxInputChars = KMaxTInt,
1.563 + TInt* aOutputChars = NULL,TInt* aInputChars = NULL);
1.564 + IMPORT_C void ExportTextL(TInt aPos,RWriteStream& aOutput,TTextOrganisation aTextOrganisation,
1.565 + TInt aMaxOutputChars = KMaxTInt,TInt aMaxInputChars = KMaxTInt,
1.566 + TInt aMaxLineLength = KMaxTInt,
1.567 + TInt* aOutputChars = NULL,TInt* aInputChars = NULL) const;
1.568 + IMPORT_C virtual TInt ImportTextFileL(TInt aPos,const TDes& aFileName,TTextOrganisation aTextOrganisation);
1.569 + IMPORT_C virtual void ExportAsTextL(const TDes& aFileName,TTextOrganisation aTextOrganisation,
1.570 + TInt aMaxLineLength) const;
1.571 +
1.572 + // import and export text AND optionally translate from or to a non-Unicode encoding
1.573 + IMPORT_C void ImportTextL(TInt aPos,RReadStream& aInput,
1.574 + const TImportExportParam& aParam,TImportExportResult& aResult);
1.575 + IMPORT_C void ExportTextL(TInt aPos,RWriteStream& aOutput,
1.576 + const TImportExportParam& aParam,TImportExportResult& aResult) const;
1.577 +
1.578 + // read and write field data
1.579 + IMPORT_C void StoreFieldComponentsL(CStreamStore& aStore,CStoreMap& aMap) const;
1.580 + IMPORT_C void RestoreFieldComponentsL(const CStreamStore& aStore);
1.581 + IMPORT_C void ExternalizeFieldDataL(RWriteStream& aStream) const;
1.582 + IMPORT_C void InternalizeFieldDataL(RReadStream& aStream);
1.583 +
1.584 + // modifier functions
1.585 + IMPORT_C virtual void Reset();
1.586 + IMPORT_C virtual void InsertL(TInt aPos,const TChar& aChar);
1.587 + IMPORT_C virtual void InsertL(TInt aPos,const TDesC& aBuf);
1.588 + IMPORT_C virtual TBool DeleteL(TInt aPos,TInt aLength);
1.589 +
1.590 + // interrogation functions
1.591 + IMPORT_C virtual TPtrC Read(TInt aStartPos) const;
1.592 + IMPORT_C virtual TPtrC Read(TInt aStartPos,TInt aLength) const;
1.593 + IMPORT_C virtual void Extract(TDes& aBuf,TInt aPos=0) const;
1.594 + IMPORT_C virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const;
1.595 +
1.596 + // Flags for ExtractSelectively
1.597 + enum
1.598 + {
1.599 + EExtractAll = 0, // extract all characters
1.600 + EExtractVisible = 1, // discard control characters and soft hyphens; change par and line separators to spaces
1.601 + EExcludeInlineEditedText = 2 // discard the inline text
1.602 + };
1.603 + IMPORT_C void ExtractSelectively(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags);
1.604 +
1.605 + // copy and paste
1.606 + IMPORT_C virtual void CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const;
1.607 + IMPORT_C virtual TInt PasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDictionary,TInt aPos);
1.608 +
1.609 + // utility functions
1.610 + IMPORT_C void SetPageTable(TPageTable* aPageTable);
1.611 + IMPORT_C TInt PageContainingPos(TInt aPos) const;
1.612 + IMPORT_C virtual TInt DocumentLength() const;
1.613 + IMPORT_C virtual TInt WordCount() const;
1.614 + IMPORT_C virtual TInt ParagraphCount() const;
1.615 + IMPORT_C virtual TInt ToParagraphStart(TInt& aPos) const;
1.616 + IMPORT_C virtual TInt CharPosOfParagraph(TInt& aLength,TInt aParaOffset) const;
1.617 + IMPORT_C virtual TInt ParagraphNumberForPos(TInt& aPos) const;
1.618 + IMPORT_C virtual void GetWordInfo(TInt aCurrentPos,TInt& aStartPos,TInt& aLength,
1.619 + TBool aPictureIsDelimiter,TBool aPunctuationIsDelimiter) const;
1.620 + IMPORT_C virtual TInt ScanWords(TInt& aPos,TUint& aScanMask) const;
1.621 + IMPORT_C virtual TInt ScanParas(TInt& aPos,TUint& aScanMask) const;
1.622 + IMPORT_C virtual TEtextComponentInfo ComponentInfo() const;
1.623 + //
1.624 + // Field functions
1.625 + IMPORT_C void SetFieldFactory(MTextFieldFactory* aFactory);
1.626 + inline const MTextFieldFactory* FieldFactory() const;
1.627 + IMPORT_C CTextField* NewTextFieldL(TUid aFieldType) const;
1.628 + IMPORT_C void InsertFieldL(TInt aPos,CTextField* aField,TUid aFieldType);
1.629 + IMPORT_C virtual void UpdateFieldL(TInt aPos);
1.630 + IMPORT_C void UpdateAllFieldsL();
1.631 + IMPORT_C TInt FieldCount() const;
1.632 + IMPORT_C const CTextField* TextField(TInt aPos) const;
1.633 + IMPORT_C TBool FindFields(TInt aPos) const;
1.634 + IMPORT_C TBool FindFields(TFindFieldInfo& aInfo,TInt aPos,TInt aRange=0) const;
1.635 + IMPORT_C TBool RemoveField(TInt aPos);
1.636 + IMPORT_C TBool ConvertFieldToText(TInt aPos);
1.637 + IMPORT_C void ConvertAllFieldsToText();
1.638 +
1.639 + IMPORT_C void ExtendedInterface(TAny*& aInterface, TUid aInterfaceId); // from CEditableText
1.640 +
1.641 +protected:
1.642 + IMPORT_C CPlainText();
1.643 + IMPORT_C void ConstructL(TDocumentStorage aStorage = ESegmentedStorage,
1.644 + TInt aDefaultTextGranularity = EDefaultTextGranularity);
1.645 + IMPORT_C void ConstructL(const CStreamStore& aStore,TStreamId aStreamId,MTextFieldFactory* aFieldFactory,
1.646 + TDocumentStorage aStorage = ESegmentedStorage);
1.647 + IMPORT_C void DoConstructL(TDocumentStorage aStorage,TInt aDefaultTextGranularity,
1.648 + MTextFieldFactory* aFieldFactory = NULL);
1.649 + void DoExtract(TDes& aBuf,TInt aPos,TInt aLength,TUint aFlags = 0) const;
1.650 + IMPORT_C void PtInsertL(TInt aInsertPos,const TDesC& aBuf);
1.651 + IMPORT_C void DoPtInsertL(TInt aPos,const TDesC& aBuf);
1.652 + IMPORT_C TBool DoPtDelete(TInt aPos,TInt aLength);
1.653 + void InsertL(TInt aPos,const CPlainText* aText);
1.654 + TBool Delete(TInt aPos,TInt aLength);
1.655 +
1.656 + // streaming
1.657 + IMPORT_C void DoExternalizeFieldDataL(RWriteStream& aStream) const;
1.658 + IMPORT_C void DoInternalizeFieldDataL(RReadStream& aStream);
1.659 + IMPORT_C void DoExternalizePlainTextL(RWriteStream& aStream) const;
1.660 + IMPORT_C void DoInternalizePlainTextL(RReadStream& aStream);
1.661 + TStreamId DoCopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDictionary,TInt aPos,TInt aLength) const;
1.662 + TInt DoPasteFromStoreL(const CStreamStore& aStore,TStreamId aStreamId,TInt aPos);
1.663 + void CopyComponentsL(CStreamStore& aStore,CStoreMap& aMap,TInt aPos,TInt aLength) const;
1.664 + void PasteComponentsL(const CStreamStore& aStore,TInt aPos);
1.665 + void CopyToStreamL(RWriteStream& aStream,TInt aPos,TInt aLength) const;
1.666 +
1.667 + // utility functions
1.668 + inline static void ConsumeAdornmentL(RReadStream& aStream);
1.669 + inline static TUid UidFromStreamL(RReadStream& aStream);
1.670 +protected:
1.671 + enum
1.672 + {
1.673 + EImportBufSize = 512,
1.674 + EBiggestCharacterPaste=0x100000
1.675 + };
1.676 +
1.677 + enum TUnitOfText
1.678 + {
1.679 + EUnitIsWord,
1.680 + EUnitIsParagraph
1.681 + };
1.682 +
1.683 + struct SScanData
1.684 + {
1.685 + TInt pos; // current character position
1.686 + TInt oldPos; // old character position
1.687 + TText* buf; // address of data (Unicode-aware)
1.688 + TInt currentSegLen; // number of characters left in segment
1.689 + TInt totalBufLen; // number of unread characters
1.690 + TInt delta; // specifies current scan direction
1.691 + TUint32 scanMask; // bitmask containing the scan settings
1.692 + enum
1.693 + {
1.694 + EInsideUnit = 0x10000000,
1.695 + EStopEnd = 0x20000000,
1.696 + EStopBegin = 0x40000000,
1.697 + EIsDelimiter = 0x80000000
1.698 + };
1.699 + };
1.700 +
1.701 +private:
1.702 + CPlainText(const CPlainText& aPlainTextDoc);
1.703 + CPlainText& operator=(const CPlainText& aPlainTextDoc);
1.704 + TInt PasteFromStreamL(RReadStream& aStream,TInt aPos);
1.705 + TInt DoPasteFromStreamL(RReadStream& aStream, TInt aPos);
1.706 + void InsertEodL();
1.707 + void InitScanControl(TInt& aPos,TUint& aScanMask,TUnitOfText aContext,SScanData& aScanData) const;
1.708 + void InitScanData(TInt aPos,SScanData& aScanData) const;
1.709 + void KillFieldSet();
1.710 + TInt CountUnits(TUnitOfText aContext) const;
1.711 + TInt ScanUnit(TInt& aPos,TUnitOfText aContext,SScanData& aScanData) const;
1.712 + TBool TestForDelimiter(TUnitOfText aContext,SScanData& aScanData) const;
1.713 + TBool GetChar(SScanData& aScanData,TChar& aChar) const;
1.714 + void UpdatePageTable(TInt aPos,TInt aLength);
1.715 + inline TBool FieldSetPresent() const;
1.716 + void CreateFieldSetL(TInt aDocumentLength);
1.717 +
1.718 + IMPORT_C virtual void Reserved_2(); // new
1.719 +
1.720 + void* iReserved_1;
1.721 +
1.722 +protected:
1.723 + CBufBase* iByteStore; // handle to document storage class.
1.724 + TSwizzle<CTextFieldSet> iFieldSet; // handle to field storage class
1.725 + TPageTable* iPageTable; // may be NULL
1.726 + MTextFieldFactory* iFieldFactory; // temporary handle to field factory during restoration
1.727 +
1.728 + __DECLARE_TEST;
1.729 + };
1.730 +
1.731 +
1.732 +#include <txtetext.inl>
1.733 +
1.734 +#endif // __TXTETEXT_H__