CPlainText Class Reference

class CPlainText : public CEditableText

Stores and manipulates plain text.

Plain text cannot be displayed, so this class provides no support for formatting. It is purely an in-memory buffer for text, and provides services that act upon it. These services include the following: import from and export to streams, optionally translating between Unicode and other encodings; reading and writing of field data; extraction of text; finding word and paragraph boundaries.

The type and size of in-memory buffer can be specified upon object construction. However, if no specification is provided a buffer is provided with default settings. There are two types of storage buffer: segmented buffers and flat buffers. The default buffer for plain text is segmented (CBufSeg). This is most efficient when a large quantity of text is to be stored, or will have a large dynamic range. A flat buffer (CBufFlat) is most appropriate for storing small quantities of text of bounded length. For most uses, however, a segmented buffer is sufficient.

Inherits from

Public Member Functions
~CPlainText()
IMPORT_C TIntCharPosOfParagraph(TInt &, TInt)
IMPORT_C TEtextComponentInfoComponentInfo()
IMPORT_C voidConvertAllFieldsToText()
IMPORT_C TBoolConvertFieldToText(TInt)
IMPORT_C voidCopyToStoreL(CStreamStore &, CStreamDictionary &, TInt, TInt)
IMPORT_C TBoolDeleteL(TInt, TInt)
IMPORT_C TIntDocumentLength()
IMPORT_C voidExportAsTextL(const TDes &, TTextOrganisation, TInt)
IMPORT_C voidExportTextL(TInt, RWriteStream &, TTextOrganisation, TInt, TInt, TInt, TInt *, TInt *)
IMPORT_C voidExportTextL(TInt, RWriteStream &, const TImportExportParam &, TImportExportResult &)
IMPORT_C voidExtendedInterface(TAny *&, TUid)
IMPORT_C voidExternalizeFieldDataL(RWriteStream &)
IMPORT_C voidExternalizeL(RWriteStream &)
IMPORT_C voidExternalizePlainTextL(RWriteStream &)
IMPORT_C voidExternalizePlainTextNoLengthCountL(RWriteStream &)
IMPORT_C voidExtract(TDes &, TInt)
IMPORT_C voidExtract(TDes &, TInt, TInt)
IMPORT_C voidExtractSelectively(TDes &, TInt, TInt, TUint)
IMPORT_C TIntFieldCount()
IMPORT_C const MTextFieldFactory *FieldFactory()
IMPORT_C TBoolFindFields(TInt)
IMPORT_C TBoolFindFields(TFindFieldInfo &, TInt, TInt)
IMPORT_C voidGetWordInfo(TInt, TInt &, TInt &, TBool, TBool)
IMPORT_C TIntImportTextFileL(TInt, const TDes &, TTextOrganisation)
IMPORT_C voidImportTextL(TInt, RReadStream &, TTextOrganisation, TInt, TInt, TInt *, TInt *)
IMPORT_C voidImportTextL(TInt, RReadStream &, const TImportExportParam &, TImportExportResult &)
IMPORT_C voidInsertFieldL(TInt, CTextField *, TUid)
IMPORT_C voidInsertL(TInt, const TChar &)
IMPORT_C voidInsertL(TInt, const TDesC &)
IMPORT_C voidInternalizeFieldDataL(RReadStream &)
IMPORT_C voidInternalizeL(RReadStream &)
IMPORT_C voidInternalizePlainTextL(RReadStream &)
IMPORT_C voidInternalizePlainTextL(RReadStream &, TInt)
IMPORT_C CPlainText *NewL(TDocumentStorage, TInt)
IMPORT_C CPlainText *NewL(const CStreamStore &, TStreamId, MTextFieldFactory *, TDocumentStorage)
IMPORT_C CTextField *NewTextFieldL(TUid)
IMPORT_C TIntPageContainingPos(TInt)
IMPORT_C TIntParagraphCount()
IMPORT_C TIntParagraphNumberForPos(TInt &)
IMPORT_C TIntPasteFromStoreL(const CStreamStore &, const CStreamDictionary &, TInt)
IMPORT_C TPtrCRead(TInt)
IMPORT_C TPtrCRead(TInt, TInt)
IMPORT_C TBoolRemoveField(TInt)
IMPORT_C voidReset()
IMPORT_C voidRestoreComponentsL(const CStreamStore &)
IMPORT_C voidRestoreFieldComponentsL(const CStreamStore &)
IMPORT_C TIntScanParas(TInt &, TUint &)
IMPORT_C TIntScanWords(TInt &, TUint &)
IMPORT_C voidSetFieldFactory(MTextFieldFactory *)
IMPORT_C voidSetPageTable(TPageTable *)
IMPORT_C voidStoreComponentsL(CStreamStore &, CStoreMap &)
IMPORT_C voidStoreFieldComponentsL(CStreamStore &, CStoreMap &)
IMPORT_C const CTextField *TextField(TInt)
IMPORT_C TIntToParagraphStart(TInt &)
IMPORT_C voidUpdateAllFieldsL()
IMPORT_C voidUpdateFieldL(TInt)
IMPORT_C TIntWordCount()
Protected Member Functions
CPlainText()
IMPORT_C voidConstructL(TDocumentStorage, TInt)
IMPORT_C voidConstructL(const CStreamStore &, TStreamId, MTextFieldFactory *, TDocumentStorage)
voidConsumeAdornmentL(RReadStream &)
voidCopyComponentsL(CStreamStore &, CStoreMap &, TInt, TInt)
voidCopyToStreamL(RWriteStream &, TInt, TInt)
TBool Delete(TInt, TInt)
IMPORT_C voidDoConstructL(TDocumentStorage, TInt, MTextFieldFactory *)
TStreamId DoCopyToStoreL(CStreamStore &, CStreamDictionary &, TInt, TInt)
IMPORT_C voidDoExternalizeFieldDataL(RWriteStream &)
IMPORT_C voidDoExternalizePlainTextL(RWriteStream &)
voidDoExtract(TDes &, TInt, TInt, TUint)
IMPORT_C voidDoInternalizeFieldDataL(RReadStream &)
IMPORT_C voidDoInternalizePlainTextL(RReadStream &)
TInt DoPasteFromStoreL(const CStreamStore &, TStreamId, TInt)
IMPORT_C TBoolDoPtDelete(TInt, TInt)
IMPORT_C voidDoPtInsertL(TInt, const TDesC &)
voidInsertL(TInt, const CPlainText *)
voidPasteComponentsL(const CStreamStore &, TInt)
IMPORT_C voidPtInsertL(TInt, const TDesC &)
TUid UidFromStreamL(RReadStream &)
Private Member Functions
CPlainText(const CPlainText &)
TInt CountUnits(TUnitOfText)
voidCreateFieldSetL(TInt)
TInt DoPasteFromStreamL(RReadStream &, TInt)
TBool FieldSetPresent()
TBool GetChar(SScanData &, TChar &)
voidInitScanControl(TInt &, TUint &, TUnitOfText, SScanData &)
voidInitScanData(TInt, SScanData &)
voidInsertEodL()
voidKillFieldSet()
TInt PasteFromStreamL(RReadStream &, TInt)
IMPORT_C voidReserved_2()
TInt ScanUnit(TInt &, TUnitOfText, SScanData &)
TBool TestForDelimiter(TUnitOfText, SScanData &)
voidUpdatePageTable(TInt, TInt)
CPlainText &operator=(const CPlainText &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
CEditableText::CancelFepInlineEdit(TBool &,TInt &,TInt &,TInt &,TInt)
CEditableText::CommitFepInlineEditL(TBool &,TInt &,TInt &,TInt &,TInt)
CEditableText::GetLengthOfInlineText()const
CEditableText::GetPositionOfInlineTextInDocument()const
CEditableText::HasChanged()const
CEditableText::OverrideFormatOfInlineTextIfApplicable(TPtrC &,TCharFormat &,TInt)const
CEditableText::RestoreL(const CStreamStore &,TStreamId)
CEditableText::SetHasChanged(TBool)
CEditableText::StartFepInlineEditL(TBool &,TInt &,TInt &,TInt &,TInt,const TDesC &,TInt,TInt,MFepInlineTextFormatRetriever &)
CEditableText::StoreL(CStreamStore &)const
CEditableText::UpdateFepInlineTextL(TBool &,TInt &,TInt &,TInt &,TInt,const TDesC &)
CEditableText::~CEditableText()
Public Member Enumerations
enumanonymous {
EScanBackwards = 0x01, EScanStayIfBoundary = 0x02, EScanToUnitStart = 0x04, EScanToUnitEnd = 0x08, EScanJoinDelimiters = 0x10, EScanPictureIsDelimiter = 0x20, EScanPunctuationIsDelimiter = 0x40
}
enumanonymous { EExtractAll = 0, EExtractVisible = 1, EExcludeInlineEditedText = 2 }
enumTScanDataEnd { EScanEndOfData = -1 }
enumTTextOrganisation { EOrganiseByParagraph, EOrganiseByLine }
Protected Member Enumerations
enumanonymous { EImportBufSize = 512, EBiggestCharacterPaste = 0x100000 }
enumTUnitOfText { EUnitIsWord, EUnitIsParagraph }
Inherited Enumerations
CEditableText:@49
CEditableText:@50
CEditableText:TDocumentStorage
Protected Attributes
__DECLARE_TEST
CBufBase *iByteStore
MTextFieldFactory *iFieldFactory
TSwizzle< CTextFieldSet >iFieldSet
TPageTable *iPageTable
Private Attributes
void *iReserved_1
Inherited Attributes
CEditableText::iHasChanged

Constructor & Destructor Documentation

CPlainText()

IMPORT_CCPlainText()[protected]

CPlainText(const CPlainText &)

CPlainText(const CPlainText &aPlainTextDoc)[private]

Parameters

const CPlainText & aPlainTextDoc

~CPlainText()

IMPORT_C~CPlainText()[virtual]

The destructor frees the object's text storage and field set, prior to its destruction.

Member Functions Documentation

CharPosOfParagraph(TInt &, TInt)

IMPORT_C TIntCharPosOfParagraph(TInt &aLength,
TIntaParaOffset
)const [virtual]

Finds the length and the start position of a paragraph identified by its paragraph number the first paragraph is numbered zero.

Notes:

if aParaOffset is invalid, (equal to or greater than the total number of paragraphs), the function's return value is EScanEndOfData

Parameters

TInt & aLengthOn return contains the length of the specified paragraph.
TInt aParaOffsetThe paragraph number. The first paragraph is numbered zero.

ComponentInfo()

IMPORT_C TEtextComponentInfoComponentInfo()const [virtual]

Gets information about the number of components contained in the text object. For plain text, only the field count has relevance.

ConstructL(TDocumentStorage, TInt)

IMPORT_C voidConstructL(TDocumentStorageaStorage = ESegmentedStorage,
TIntaDefaultTextGranularity = EDefaultTextGranularity
)[protected]

Allocates storage of CBufFlat or CBufSeg, according to the parameter aStorage. Creates & initializes the field set.

Parameters

TDocumentStorage aStorage = ESegmentedStorage
TInt aDefaultTextGranularity = EDefaultTextGranularity

ConstructL(const CStreamStore &, TStreamId, MTextFieldFactory *, TDocumentStorage)

IMPORT_C voidConstructL(const CStreamStore &aStore,
TStreamIdaStreamId,
MTextFieldFactory *aFieldFactory,
TDocumentStorageaStorage = ESegmentedStorage
)[protected]

Allocates storage of CBufFlat or CBufSeg, according to the parameter aStorage, restoring contents from the specified read-stream aStream.

Parameters

const CStreamStore & aStore
TStreamId aStreamId
MTextFieldFactory * aFieldFactory
TDocumentStorage aStorage = ESegmentedStorage

ConsumeAdornmentL(RReadStream &)

voidConsumeAdornmentL(RReadStream &aStream)[protected, static, inline]

Parameters

RReadStream & aStream

ConvertAllFieldsToText()

IMPORT_C voidConvertAllFieldsToText()

Removes all fields from the text object's field set, leaving their current text value in the text object. Does not update the fields beforehand.

ConvertFieldToText(TInt)

IMPORT_C TBoolConvertFieldToText(TIntaPos)

Converts the field containing the specified document position into text, leaving its current value in the text object. Does not update the field beforehand.

Parameters

TInt aPosA document position within the field to convert. Must be a valid position or a panic occurs.

CopyComponentsL(CStreamStore &, CStoreMap &, TInt, TInt)

voidCopyComponentsL(CStreamStore &aStore,
CStoreMap &aMap,
TIntaPos,
TIntaLength
)const [protected]

Parameters

CStreamStore & aStore
CStoreMap & aMap
TInt aPos
TInt aLength

CopyToStoreL(CStreamStore &, CStreamDictionary &, TInt, TInt)

IMPORT_C voidCopyToStoreL(CStreamStore &aStore,
CStreamDictionary &aDictionary,
TIntaPos,
TIntaLength
)const [virtual]

Copies plain text including fields, if present, to the clipboard.

A panic occurs in any of the following circumstances:

aPos is invalid

aLength is invalid (zero or less)

the sum of aPos and aLength is greater than or equal to the number of characters in the document

Parameters

CStreamStore & aStoreStream store to which the text is written.
CStreamDictionary & aDictionaryThe stream dictionary.
TInt aPosThe document position from which to begin copying.
TInt aLengthThe number of characters to copy.

CopyToStreamL(RWriteStream &, TInt, TInt)

voidCopyToStreamL(RWriteStream &aStream,
TIntaPos,
TIntaLength
)const [protected]

Parameters

RWriteStream & aStream
TInt aPos
TInt aLength

CountUnits(TUnitOfText)

TInt CountUnits(TUnitOfTextaContext)const [private]

Parameters

TUnitOfText aContext

CreateFieldSetL(TInt)

voidCreateFieldSetL(TIntaDocumentLength)[private]

Parameters

TInt aDocumentLength

Delete(TInt, TInt)

TBool Delete(TIntaPos,
TIntaLength
)[protected]

Parameters

TInt aPos
TInt aLength

DeleteL(TInt, TInt)

IMPORT_C TBoolDeleteL(TIntaPos,
TIntaLength
)[virtual]

Deletes one or more characters beginning at, and including, the character at a specified document position. Updates the page table. Any fields wholly contained in the range of characters to delete are removed from the field set.

Parameters

TInt aPosThe document position from which to begin deleting. Must be valid or a panic occurs.
TInt aLengthThe number of characters to delete. Must be positive or a panic occurs. The sum of aPos and aLength must be less than the document length, or a panic occurs.

DoConstructL(TDocumentStorage, TInt, MTextFieldFactory *)

IMPORT_C voidDoConstructL(TDocumentStorageaStorage,
TIntaDefaultTextGranularity,
MTextFieldFactory *aFieldFactory = NULL
)[protected]

Allocates storage of CBufFlat or CBufSeg, according to the parameter aStorage. Creates & initializes the field set.

Parameters

TDocumentStorage aStorage
TInt aDefaultTextGranularity
MTextFieldFactory * aFieldFactory = NULL

DoCopyToStoreL(CStreamStore &, CStreamDictionary &, TInt, TInt)

TStreamId DoCopyToStoreL(CStreamStore &aStore,
CStreamDictionary &aDictionary,
TIntaPos,
TIntaLength
)const [protected]

Parameters

CStreamStore & aStore
CStreamDictionary & aDictionary
TInt aPos
TInt aLength

DoExternalizeFieldDataL(RWriteStream &)

IMPORT_C voidDoExternalizeFieldDataL(RWriteStream &aStream)const [protected]

Write to the stream, the T.V. representing the field set.

Parameters

RWriteStream & aStream

DoExternalizePlainTextL(RWriteStream &)

IMPORT_C voidDoExternalizePlainTextL(RWriteStream &aStream)const [protected]

Write to the stream, the T.V. representing the plain text.

Parameters

RWriteStream & aStream

DoExtract(TDes &, TInt, TInt, TUint)

voidDoExtract(TDes &aBuf,
TIntaPos,
TIntaLength,
TUintaFlags = 0
)const [protected]

Copies aLength characters, commencing at aPos, into the specified buffer aBuf. If aLength is greater than the amount of data left, then all remaining characters are written.

Parameters

TDes & aBuf
TInt aPos
TInt aLength
TUint aFlags = 0

DoInternalizeFieldDataL(RReadStream &)

IMPORT_C voidDoInternalizeFieldDataL(RReadStream &aStream)[protected]

Read from the stream until the field data is identified, and consume it.

Parameters

RReadStream & aStream

DoInternalizePlainTextL(RReadStream &)

IMPORT_C voidDoInternalizePlainTextL(RReadStream &aStream)[protected]

Read from the stream until the character data is found, and consume it.

Parameters

RReadStream & aStream

DoPasteFromStoreL(const CStreamStore &, TStreamId, TInt)

TInt DoPasteFromStoreL(const CStreamStore &aStore,
TStreamIdaStreamId,
TIntaPos
)[protected]

Parameters

const CStreamStore & aStore
TStreamId aStreamId
TInt aPos

DoPasteFromStreamL(RReadStream &, TInt)

TInt DoPasteFromStreamL(RReadStream &aStream,
TIntaPos
)[private]

Parameters

RReadStream & aStream
TInt aPos

DoPtDelete(TInt, TInt)

IMPORT_C TBoolDoPtDelete(TIntaPos,
TIntaLength
)[protected]

Deletes aLength number of characters from the document, commencing at, and including, position aPos. The return value indicates if 2 paragraphs have been merged together as a result of the delete, indicating that the resulting paragraph must be reformatted. In global text, this clearly has no reasonable meaning, so always returns EFalse, so no reformatting occurs.

Parameters

TInt aPos
TInt aLength

DoPtInsertL(TInt, const TDesC &)

IMPORT_C voidDoPtInsertL(TIntaPos,
const TDesC &aBuf
)[protected]

Inserts the contents a aBuf into the document at position aInsertPos. Maintain field set.

Parameters

TInt aPos
const TDesC & aBuf

DocumentLength()

IMPORT_C TIntDocumentLength()const [virtual]

Gets the the number of characters in the text object.

Note: the count includes all non-printing characters but excludes the end of text paragraph delimiter, so that the smallest possible return value is zero.

ExportAsTextL(const TDes &, TTextOrganisation, TInt)

IMPORT_C voidExportAsTextL(const TDes &aFileName,
TTextOrganisationaTextOrganisation,
TIntaMaxLineLength
)const [virtual]

Writes the contents of the plain text object to a text file.

The filename is given by aFileName. Any existing file with that name is replaced. A wrap width can be specified. This is only used when exporting by line (aTextOrganisation is EOrganiseByLine).

The function leaves if there is any problem in creating or replacing the file.

Parameters

const TDes & aFileNameThe name of the file to export the text to. If a file with this name already exists, it is replaced. Otherwise, a new file is created.
TTextOrganisation aTextOrganisationDefines how to translate line delimiters. If EOrganiseByLine, lines wrap at the wrap width, as specified in aMaxLineLength. If EOrganiseByParagraph, lines do not wrap and paragraph delimiters are converted into CR/LF pairs.
TInt aMaxLineLengthThe maximum number of characters in each line, (only relevant if the text organisation is EOrganiseByLine).

ExportTextL(TInt, RWriteStream &, TTextOrganisation, TInt, TInt, TInt, TInt *, TInt *)

IMPORT_C voidExportTextL(TIntaPos,
RWriteStream &aOutput,
TTextOrganisationaTextOrganisation,
TIntaMaxOutputChars =  KMaxTInt ,
TIntaMaxInputChars =  KMaxTInt ,
TIntaMaxLineLength =  KMaxTInt ,
TInt *aOutputChars = NULL,
TInt *aInputChars = NULL
)const

Writes plain text to a stream, optionally converting it from Unicode into a foreign encoding.

Since
6.1

Parameters

TInt aPosA document position in the source plain text object from which to start reading the text to export.
RWriteStream & aOutputOn return, the write stream to which the text is written.
TTextOrganisation aTextOrganisation
TInt aMaxOutputChars =  KMaxTInt
TInt aMaxInputChars =  KMaxTInt
TInt aMaxLineLength =  KMaxTInt
TInt * aOutputChars = NULL
TInt * aInputChars = NULL

ExportTextL(TInt, RWriteStream &, const TImportExportParam &, TImportExportResult &)

IMPORT_C voidExportTextL(TIntaPos,
RWriteStream &aOutput,
const TImportExportParam &aParam,
TImportExportResult &aResult
)const

Writes plain text to a stream, optionally converting it from Unicode into a foreign encoding.

CPlainText::TImportExportParam CPlainText::TImportExportResult

Parameters

TInt aPosA document position in the source plain text object from which to start reading the text to export.
RWriteStream & aOutputOn return, the write stream to which the text is written.
const TImportExportParam & aParamExport parameters, including an optional foreign encoding to convert the Unicode text into, a file server connection, (this is needed for the character conversion if not specified, one will be created), a line wrap width, and the maximum number of characters to export.
TImportExportResult & aResultOn return, contains the number of characters read and written.

ExtendedInterface(TAny *&, TUid)

IMPORT_C voidExtendedInterface(TAny *&aInterface,
TUidaInterfaceId
)[virtual]

Returns the interface corresponding to the specified UID if it exists, or 0 if not. Overridden versions should base call rather than returning 0.

Parameters

TAny *& aInterfaceThe interface corresponding to aInterfaceId if it is supported, or 0 if it is not
TUid aInterfaceIdThe UID indicating the interface to return

ExternalizeFieldDataL(RWriteStream &)

IMPORT_C voidExternalizeFieldDataL(RWriteStream &aStream)const

Externalises the plain text object's field set.

Parameters

RWriteStream & aStreamThe stream to which the field set should be written.

ExternalizeL(RWriteStream &)

IMPORT_C voidExternalizeL(RWriteStream &aStream)const [virtual]

Externalises a plain text object to a write stream. The presence of this function means that the standard templated operator<<() (defined in s32strm.h) is available to externalise objects of this class.

Parameters

RWriteStream & aStreamStream to which the object should be externalised.

ExternalizePlainTextL(RWriteStream &)

IMPORT_C voidExternalizePlainTextL(RWriteStream &aStream)const

Externalises the plain text object's text content (preceded by a length count) to a write stream.

Parameters

RWriteStream & aStreamStream to which the text content should be externalised.

ExternalizePlainTextNoLengthCountL(RWriteStream &)

IMPORT_C voidExternalizePlainTextNoLengthCountL(RWriteStream &aStream)const

Externalises the plain text object's text content to a write stream.

This function differs from ExternalizePlainTextL() in that it does not precede the text content with a length count. This function is not intended for general use and is deprecated. void CPlainText::ExternalizePlainTextL(RWriteStream& aStream)const

Parameters

RWriteStream & aStream

Extract(TDes &, TInt)

IMPORT_C voidExtract(TDes &aBuf,
TIntaPos = 0
)const [virtual]

Copies the contents of the text object into a descriptor overloaded function. The function copies all characters from and including the document position specified, to the end of the document or the end of the range of characters, if specified.

The buffer's maximum length must be greater than or equal to the number of characters to extract, or a panic occurs.

Parameters

TDes & aBufA buffer; on return contains the extracted text.
TInt aPos = 0The document position from which to copy. Must be valid or a panic occurs.

Extract(TDes &, TInt, TInt)

IMPORT_C voidExtract(TDes &aBuf,
TIntaPos,
TIntaLength
)const [virtual]

Copies the contents of the text object into a descriptor-overloaded function. The function copies all characters from and including the document position specified, to the end of the document or the end of the range of characters, if specified.

The buffer's maximum length must be greater than or equal to aLength, or a panic ocurs.

Parameters

TDes & aBufA buffer; on return contains the extracted text.
TInt aPosThe document position from which to copy. Must be valid or a panic occurs.
TInt aLengthThe number of characters to copy.

ExtractSelectively(TDes &, TInt, TInt, TUint)

IMPORT_C voidExtractSelectively(TDes &aBuf,
TIntaPos,
TIntaLength,
TUintaFlags
)

Parameters

TDes & aBuf
TInt aPos
TInt aLength
TUint aFlags

FieldCount()

IMPORT_C TIntFieldCount()const

Gets a count of the number of fields in the text object's field set.

FieldFactory()

IMPORT_C const MTextFieldFactory *FieldFactory()const

Gets a pointer to the field factory used by the text object. The field factory may be set up using SetFieldFactory(), or may be specified in the NewL().

FieldSetPresent()

TBool FieldSetPresent()const [private, inline]

FindFields(TInt)

IMPORT_C TBoolFindFields(TIntaPos)const

Parameters

TInt aPos

FindFields(TFindFieldInfo &, TInt, TInt)

IMPORT_C TBoolFindFields(TFindFieldInfo &aInfo,
TIntaPos,
TIntaRange = 0
)const

Tests whether a document position is located within a field overloaded function.

The second overload extracts information about all fields located within a range of characters.

Parameters

TFindFieldInfo & aInfoOn return, contains the number of fields fully or partially within the range of characters specified and the start position and length of the first field found.
TInt aPosThe document position. Must be valid or a panic occurs.
TInt aRange = 0The number of characters to search, beginning at aPos. Must not be negative, or a panic occurs. The sum of aPos and aRange must be less than the document length, or a panic occurs. The default range is zero. In this case the function just returns information about the single field located at the position specified.

GetChar(SScanData &, TChar &)

TBool GetChar(SScanData &aScanData,
TChar &aChar
)const [private]

Parameters

SScanData & aScanData
TChar & aChar

GetWordInfo(TInt, TInt &, TInt &, TBool, TBool)

IMPORT_C voidGetWordInfo(TIntaCurrentPos,
TInt &aStartPos,
TInt &aLength,
TBoolaPictureIsDelimiter,
TBoolaPunctuationIsDelimiter
)const [virtual]

Gets the start position and length of the word that contains the document position specified.

Parameters

TInt aCurrentPosA document position. Must be valid or a panic occurs.
TInt & aStartPosOn return, the document position of the first character in the word containing the position aCurrentPos.
TInt & aLengthOn return, the length of the word containing document position aCurrentPos.
TBool aPictureIsDelimiterETrue if picture characters should be treated as word delimiters, false if not. For example, when navigating text, this might be EFalse, but when spell checking, it might be ETrue.
TBool aPunctuationIsDelimiterETrue if punctuation characters should be treated as word delimiters, EFalse if not.

ImportTextFileL(TInt, const TDes &, TTextOrganisation)

IMPORT_C TIntImportTextFileL(TIntaPos,
const TDes &aFileName,
TTextOrganisationaTextOrganisation
)[virtual]

Imports a plain text file into this text object.

Translates non-printing characters in the source text file into Symbian OS special characters, for instance tabs are converted into CEditableText::ETabCharacters, and form feeds into CEditableText::EPageBreaks. Line feeds in the source text file are translated according to the aTextOrganisation argument.

The function leaves if there is any problem in opening the file.

Parameters

TInt aPosDocument position at which to insert the text. Must be a valid position, or a panic occurs.
const TDes & aFileNameThe name of the text file to import.
TTextOrganisation aTextOrganisationIf EOrganiseByLine, a single line feed or a line feed and carriage return is converted into a space character. A line feed which is followed by another line feed is converted into a paragraph delimiter. If EOrganiseByParagraph, all line feeds are converted into paragraph delimiters.

ImportTextL(TInt, RReadStream &, TTextOrganisation, TInt, TInt, TInt *, TInt *)

IMPORT_C voidImportTextL(TIntaPos,
RReadStream &aInput,
TTextOrganisationaTextOrganisation,
TIntaMaxOutputChars =  KMaxTInt ,
TIntaMaxInputChars =  KMaxTInt ,
TInt *aOutputChars = NULL,
TInt *aInputChars = NULL
)

Imports plain text from a stream into this text object.

Translates line feeds in the source text according to the aTextOrganisation argument.

Parameters

TInt aPosDocument position at which to insert the text. Must be a valid position, or a panic occurs.
RReadStream & aInputStream from which to read the text.
TTextOrganisation aTextOrganisationIf EOrganiseByLine, a single line feed or a line feed and carriage return is converted into a space character. A line feed which is followed by another line feed is converted into a paragraph delimiter. If EOrganiseByParagraph, all line feeds are converted into paragraph delimiters.
TInt aMaxOutputChars =  KMaxTInt The maximum number of characters to write to the text object.
TInt aMaxInputChars =  KMaxTInt The maximum number of characters to read from the stream.
TInt * aOutputChars = NULLOn return, the number of characters written to the text object.
TInt * aInputChars = NULLOn return, the number of characters read from the stream.

ImportTextL(TInt, RReadStream &, const TImportExportParam &, TImportExportResult &)

IMPORT_C voidImportTextL(TIntaPos,
RReadStream &aInput,
const TImportExportParam &aParam,
TImportExportResult &aResult
)

Imports plain text from a stream into this text object, optionally converting it from a foreign encoding into Unicode.

CPlainText::TImportExportParam CPlainText::TImportExportResult

Parameters

TInt aPosDocument position at which to insert the text. Must be a valid position, or a panic occurs.
RReadStream & aInputStream from which to read the text.
const TImportExportParam & aParamImport parameters, including the foreign encoding to convert from, whether to guess the foreign encoding and the maximum number of characters to import.
TImportExportResult & aResultOn return, contains the number of characters read and written and the foreign encoding used by the imported text.

InitScanControl(TInt &, TUint &, TUnitOfText, SScanData &)

voidInitScanControl(TInt &aPos,
TUint &aScanMask,
TUnitOfTextaContext,
SScanData &aScanData
)const [private]

Parameters

TInt & aPos
TUint & aScanMask
TUnitOfText aContext
SScanData & aScanData

InitScanData(TInt, SScanData &)

voidInitScanData(TIntaPos,
SScanData &aScanData
)const [private]

Parameters

TInt aPos
SScanData & aScanData

InsertEodL()

voidInsertEodL()[private]

Inserts the end-of-document character upon document construction.

InsertFieldL(TInt, CTextField *, TUid)

IMPORT_C voidInsertFieldL(TIntaPos,
CTextField *aField,
TUidaFieldType
)

Inserts a field into the text object at a specified document position. creating a zero-length field record. Maintain the field set.

Note: After insertion, the field should be evaluated in order to make its contents visible; use UpdateFieldL().

Parameters

TInt aPosThe document position at which to insert the field. Must be valid, or a panic occurs.
CTextField * aFieldThe field to insert, created by NewTextFieldL(). Must not be NULL, or a panic occurs.
TUid aFieldTypeIdentifies the type of field to insert. For the built in field types, see the UID values defined in flddef.h.

InsertL(TInt, const TChar &)

IMPORT_C voidInsertL(TIntaPos,
const TChar &aChar
)[virtual]

Inserts either a single character or a descriptor into the text object at a specified document position.

Updates the page table.

Parameters

TInt aPosThe document position at which to insert the character/descriptor. Must be valid, or a panic occurs.
const TChar & aCharThe character to insert.

InsertL(TInt, const TDesC &)

IMPORT_C voidInsertL(TIntaPos,
const TDesC &aBuf
)[virtual]

Inserts the contents of aBuf into the document at position aPos.

Parameters

TInt aPos
const TDesC & aBuf

InsertL(TInt, const CPlainText *)

voidInsertL(TIntaPos,
const CPlainText *aText
)[protected]

Insert the specified plain text object at the specified character position. (Called by CRichText::Insert()

Parameters

TInt aPos
const CPlainText * aText

InternalizeFieldDataL(RReadStream &)

IMPORT_C voidInternalizeFieldDataL(RReadStream &aStream)

Internalizes the field set.

Parameters

RReadStream & aStreamThe read stream from which the field set is read.

InternalizeL(RReadStream &)

IMPORT_C voidInternalizeL(RReadStream &aStream)[virtual]

Internalises the text object's text content and field set from a read stream. The presence of this function means that the standard templated operator>>() (defined in s32strm.h) is available to internalise objects of this class. InternalizeL() has construct rather than assignment semantics. You should not use it for fully initialised objects.

Parameters

RReadStream & aStreamStream from which the object should be internalised.

InternalizePlainTextL(RReadStream &)

IMPORT_C voidInternalizePlainTextL(RReadStream &aStream)

Internalises an empty text object's text content from a read stream overloaded function.

This function has construct rather than assignment semantics. You should not use it for fully initialised objects.NoteThe overload which takes a length argument is not intended for general use and its use is deprecated.

Parameters

RReadStream & aStreamStream from which the object should be internalised.

InternalizePlainTextL(RReadStream &, TInt)

IMPORT_C voidInternalizePlainTextL(RReadStream &aStream,
TIntaLength
)

Internalises an empty text object's text content from a read stream's overloaded function.

This function has construct rather than assignment semantics. You should not use it for fully initialised objects.

Note

The overload which takes a length argument is not intended for general use and its use is deprecated.

Parameters

RReadStream & aStreamStream from which the object should be internalised.
TInt aLengthIndicates the number of characters which should be read, after expansion from their compressed format.

KillFieldSet()

voidKillFieldSet()[private]

Delete the field set if it is resident in memory.

NewL(TDocumentStorage, TInt)

IMPORT_C CPlainText *NewL(TDocumentStorageaStorage = ESegmentedStorage,
TIntaDefaultTextGranularity = EDefaultTextGranularity
)[static]

Allocates and constructs a plain text object overloaded function.

The text object's contents may be restored from a stream store. If the text object supports fields, a field factory should be specified.

Parameters

TDocumentStorage aStorage = ESegmentedStorageThe type of in-memory buffer to use. Defaults to ESegmentedStorage.
TInt aDefaultTextGranularity = EDefaultTextGranularitySpecifies the granularity of the in-memory buffer. Default is EDefaultTextGranularity bytes (=256).

NewL(const CStreamStore &, TStreamId, MTextFieldFactory *, TDocumentStorage)

IMPORT_C CPlainText *NewL(const CStreamStore &aStore,
TStreamIdaStreamId,
MTextFieldFactory *aFieldFactory = NULL,
TDocumentStorageaStorage = ESegmentedStorage
)[static]

Returns a handle to a new instance of this class, restored from the specified read stream.

Parameters

const CStreamStore & aStore
TStreamId aStreamId
MTextFieldFactory * aFieldFactory = NULL
TDocumentStorage aStorage = ESegmentedStorage

NewTextFieldL(TUid)

IMPORT_C CTextField *NewTextFieldL(TUidaFieldType)const

Creates and returns a new field. Before calling this function, a field factory should have been set up, either by calling SetFieldFactory(), or by specifying one in the NewL(). The field factory's NewFieldL() function is called to create a field of the type specified in the argument. A NULL field is returned if no field factory has been set up.

Parameters

TUid aFieldTypeIdentifies the field type.

PageContainingPos(TInt)

IMPORT_C TIntPageContainingPos(TIntaPos)const

Gets the number of the page which contains the specified document position. If no page table has been set up, the function returns a value of zero. Use SetPageTable() to set up the page table.

Parameters

TInt aPosA document position. Must be valid or a panic occurs.

ParagraphCount()

IMPORT_C TIntParagraphCount()const [virtual]

Gets a count of the number of paragraphs in the text object.

Note: the paragraph delimiter which terminates every text object means this function always returns a count of at least one.

ParagraphNumberForPos(TInt &)

IMPORT_C TIntParagraphNumberForPos(TInt &aPos)const [virtual]

Gets the number of the paragraph which contains a document position. Paragraph numbering begins at zero.

Parameters

TInt & aPosA document position. Must be valid or a panic occurs. On return, contains the document position of the first character in the paragraph in which it is located.

PasteComponentsL(const CStreamStore &, TInt)

voidPasteComponentsL(const CStreamStore &aStore,
TIntaPos
)[protected]

Parameters

const CStreamStore & aStore
TInt aPos

PasteFromStoreL(const CStreamStore &, const CStreamDictionary &, TInt)

IMPORT_C TIntPasteFromStoreL(const CStreamStore &aStore,
const CStreamDictionary &aDictionary,
TIntaPos
)[virtual]

Pastes plain text and fields, if present, from the clipboard into the current text object at the specified document position. The entire contents of the store are pasted.

Parameters

const CStreamStore & aStoreThe steam store from which to paste the text.
const CStreamDictionary & aDictionaryThe stream dictionary.
TInt aPosDocument position at which to paste. Must be valid or the function raises a panic.

PasteFromStreamL(RReadStream &, TInt)

TInt PasteFromStreamL(RReadStream &aStream,
TIntaPos
)[private]

Parameters

RReadStream & aStream
TInt aPos

PtInsertL(TInt, const TDesC &)

IMPORT_C voidPtInsertL(TIntaInsertPos,
const TDesC &aBuf
)[protected]

Inserts the contents a aBuf into the document at position aInsertPos. Maintain field set.

Parameters

TInt aInsertPos
const TDesC & aBuf

Read(TInt)

IMPORT_C TPtrCRead(TIntaStartPos)const [virtual]

Gets a read-only view of a portion of the text object.

The extent of the view is the range of characters starting at aStartPos and ending at whichever of the following document positions is reached first:

  • The end of the document.

  • The end of the segment if using segmented storage (the storage type is specified in the NewL().

Therefore, when using a segmented buffer to store the document, the length of the resultant view may be less than the requested length. In this case multiple calls to Read() may be necessary.

Parameters

TInt aStartPosThe document position at which to begin reading. Must be valid or a panic occurs.

Read(TInt, TInt)

IMPORT_C TPtrCRead(TIntaStartPos,
TIntaLength
)const [virtual]

Gets a read-only view of a portion of the text object.

The extent of the view is the range of characters starting at aStartPos and ending at whichever of the following document positions is reached first:

  • The end of the document.

  • The end of the segment if using segmented storage (the storage type is specified in the NewL().

  • The sum of aStartPos and (aLength-1).

Therefore, when using a segmented buffer to store the document, the length of the resultant view may be less than the requested length. In this case multiple calls to Read() may be necessary.

Parameters

TInt aStartPosThe document position at which to begin reading. Must be valid or a panic occurs.
TInt aLengthThe number of characters to read, inclusive of the character at position aStartPos.

RemoveField(TInt)

IMPORT_C TBoolRemoveField(TIntaPos)

Removes the field covering the document position specified from the field set, and deletes all text content associated with the field from the text object.

Parameters

TInt aPosA document position within the field to be deleted. Must be a valid position or a panic occurs.

Reserved_2()

IMPORT_C voidReserved_2()[private, virtual]

Reset()

IMPORT_C voidReset()[virtual]

Deletes all text content, formatting and fields from the document, leaving the single paragraph delimiter which terminates the text object.

RestoreComponentsL(const CStreamStore &)

IMPORT_C voidRestoreComponentsL(const CStreamStore &aStore)[virtual]

Restores the plain text object's field set from a stream store.

Parameters

const CStreamStore & aStoreThe stream store from which the field set is restored.

RestoreFieldComponentsL(const CStreamStore &)

IMPORT_C voidRestoreFieldComponentsL(const CStreamStore &aStore)

Restores the plain text object's field set.

Parameters

const CStreamStore & aStoreThe stream store from which the fields are restored.

ScanParas(TInt &, TUint &)

IMPORT_C TIntScanParas(TInt &aPos,
TUint &aScanMask
)const [virtual]

Scans from a document position to the beginning or end of a paragraph. The destination is determined by a scan mask. The scan can either be forwards (the default) or backwards, and the destination may be the first or last character in the paragraph containing the position, or the first character in the next paragraph.

Note: if an attempt is made to scan beyond the end of text delimiter, on return, aPos is set to EScanEndOfData ) and the function's return value indicates the number of characters skipped in passing the end of text delimiter.

Parameters

TInt & aPosThe document position to scan from. Must be valid or a panic occurs. On return, contains the new document position.
TUint & aScanMaskThe scan mask. See the enumeration whose values begin with CPlainText::EScanBackwards.

ScanUnit(TInt &, TUnitOfText, SScanData &)

TInt ScanUnit(TInt &aPos,
TUnitOfTextaContext,
SScanData &aScanData
)const [private]

Parameters

TInt & aPos
TUnitOfText aContext
SScanData & aScanData

ScanWords(TInt &, TUint &)

IMPORT_C TIntScanWords(TInt &aPos,
TUint &aScanMask
)const [virtual]

Scans from a document position to the beginning or end of a word. The destination is determined by a scan mask. The scan can either be forwards (the default) or backwards, and the destination may be the first or last character in the word containing the position, or the first character in the next word.

Note: If an attempt is made to scan beyond the end of text delimiter, on return, aPos is set to EScanEndOfData and the function's return value indicates the number of characters skipped in passing the end of text delimiter.

Parameters

TInt & aPosThe document position from which to scan. Must be valid, or a panic occurs. On return, contains the new document position.
TUint & aScanMaskThe scan mask. See the enumeration whose values begin with CPlainText::EScanBackwards.

SetFieldFactory(MTextFieldFactory *)

IMPORT_C voidSetFieldFactory(MTextFieldFactory *aFactory)

Sets up a field factory. A field factory is an instance of a class deriving from MTextFieldFactory. It must implement a NewFieldL() function to create and return fields of the desired type. The field factory's NewFieldL() function is called by CPlainText::NewTextFieldL(). A field factory must be set up if you intend to add any fields to the text object.

Parameters

MTextFieldFactory * aFactoryThe field factory.

SetPageTable(TPageTable *)

IMPORT_C voidSetPageTable(TPageTable *aPageTable)

Links the text object to a page table. A page table is an array of integers; each integer represents the number of characters on a page. It is required for pagination. The page table is updated when changes are made to the document, e.g. after pasting from the clipboard, inserting, importing or deleting text.

The text object does not take ownership of the page table specified.

Parameters

TPageTable * aPageTableThe page table to be referenced by the text object.

StoreComponentsL(CStreamStore &, CStoreMap &)

IMPORT_C voidStoreComponentsL(CStreamStore &aStore,
CStoreMap &aMap
)const [virtual]

Stores the plain text object's components to the stream store specified.

Parameters

CStreamStore & aStoreStream store to which the text object's components are written.
CStoreMap & aMapA store map. This binds the address of each component to the stream ID of aStore. This is needed to support the deferred loading of pictures in rich text.

StoreFieldComponentsL(CStreamStore &, CStoreMap &)

IMPORT_C voidStoreFieldComponentsL(CStreamStore &aStore,
CStoreMap &aMap
)const

Stores the plain text object's field components to a stream store.

Parameters

CStreamStore & aStoreStream store to which the fields are written.
CStoreMap & aMapA store map. This binds the address of each text component to the stream ID of aStore. This is needed to support the deferred loading of pictures in rich text.

TestForDelimiter(TUnitOfText, SScanData &)

TBool TestForDelimiter(TUnitOfTextaContext,
SScanData &aScanData
)const [private]

Return ETrue if a character was read successfully. Set EIsDelimiter flag if the character read is a delimiter of the appropriate type.

Parameters

TUnitOfText aContext
SScanData & aScanData

TextField(TInt)

IMPORT_C const CTextField *TextField(TIntaPos)const

Returns a pointer to the field located at the specified document position.

Parameters

TInt aPosA document position within the field. Must be a valid document position, or a panic occurs.

ToParagraphStart(TInt &)

IMPORT_C TIntToParagraphStart(TInt &aPos)const [virtual]

Gets the document position of the start of the paragraph containing the specified document position.

Parameters

TInt & aPosA document position. Must be valid or a panic occurs. On return, contains the document position of the first character in the paragraph in which it is located.

UidFromStreamL(RReadStream &)

TUid UidFromStreamL(RReadStream &aStream)[protected, static, inline]

Parameters

RReadStream & aStream

UpdateAllFieldsL()

IMPORT_C voidUpdateAllFieldsL()

Re-evaluates all of the fields in the text object. Re-evaluating a field means calculating the field's new value, then inserting that value into the text object, replacing the previous value.

Note: Fields have a maximum length of 20 characters.

UpdateFieldL(TInt)

IMPORT_C voidUpdateFieldL(TIntaPos)[virtual]

Re-evaluates the field which covers the document position specified. Re-evaluating a field means calculating the field's new value, then inserting that value into the text object, replacing the previous value.

Notes:

fields have a maximum length of 20 characters.

the first time a field is updated, the position specified should be the position at which the field was inserted.

Parameters

TInt aPosA document position in the field to be updated. Must be a valid position, or a panic occurs.

UpdatePageTable(TInt, TInt)

voidUpdatePageTable(TIntaPos,
TIntaLength
)[private]

Parameters

TInt aPos
TInt aLength

WordCount()

IMPORT_C TIntWordCount()const [virtual]

Gets a count of the number of words in the text object.

operator=(const CPlainText &)

CPlainText &operator=(const CPlainText &aPlainTextDoc)[private]

Parameters

const CPlainText & aPlainTextDoc

Member Enumerations Documentation

Enum anonymous

Scan mask values.

Enumerators

EScanBackwards = 0x01

Scan direction is backwards. The default is forwards.

EScanStayIfBoundary = 0x02

If the current document position is a word or paragraph boundary, no scan occurs.

EScanToUnitStart = 0x04

Scan to the first character in the word or paragraph.

EScanToUnitEnd = 0x08

Scan to the last character in the word or paragraph.

EScanJoinDelimiters = 0x10

Treat adjacent word or paragraph delimiters as a single delimiter. Required when performing a word count, for example.

EScanPictureIsDelimiter = 0x20

Picture characters are considered to be word delimiters.

EScanPunctuationIsDelimiter = 0x40

Punctuation characters, except hyphens and apostrophes, are considered to be word delimiters.

Enum anonymous

Enumerators

EExtractAll = 0
EExtractVisible = 1
EExcludeInlineEditedText = 2

Enum anonymous

Enumerators

EImportBufSize = 512
EBiggestCharacterPaste = 0x100000

Enum TScanDataEnd

Used in text scanning functions to indicate the end of the document has been passed.

Enumerators

EScanEndOfData = -1

Indicates that a scan has passed the end of text paragraph delimiter.

Enum TTextOrganisation

Line delimiter translation.

Enumerators

EOrganiseByParagraph

When importing text from a text file, all line feeds are converted into paragraph delimiters.

When exporting text to a text file, lines do not wrap and paragraph delimiters are converted into CR/LF pairs.

EOrganiseByLine

When importing text from a text file, a single line feed or a line feed followed by a carriage return is converted into a space character. A line feed which is followed by another line feed is converted into a CEditableText::EParagraphDelimiter.

When exporting text to a text file, lines wrap at the specified wrap width and paragraph delimiters are converted into CR/LFs pairs.

Enum TUnitOfText

Enumerators

EUnitIsWord
EUnitIsParagraph

Member Data Documentation

__DECLARE_TEST

__DECLARE_TEST[protected]

CBufBase * iByteStore

CBufBase *iByteStore[protected]

MTextFieldFactory * iFieldFactory

MTextFieldFactory *iFieldFactory[protected]

TSwizzle< CTextFieldSet > iFieldSet

TSwizzle< CTextFieldSet >iFieldSet[protected]

TPageTable * iPageTable

TPageTable *iPageTable[protected]

void * iReserved_1

void *iReserved_1[private]