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