Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: txtglobl.h
Link against: etext.lib

Class CGlobalText

CGlobalText

Support

Supported from 5.0

Description

Text with globally applied formatting. Global text uses a single set of paragraph format attributes to describe the appearance of every paragraph and a single set of character format attributes to describe the appearance of every character.

The paragraph formatting is stored in a CParaFormatLayer and the character formatting is stored in a CCharFormatLayer. A format layer is a set of character or paragraph format attributes, which may own a pointer to another format layer. This pointer is called a based-on link. The effective formatting of a global text object is the set of attributes specified in its two format layers, as well as any attributes inherited from the layers' chain of based-on links. To get the effective formatting, the links are read in turn, so that each attribute's value is taken from the first layer in the chain in which it has been set. Use GetCharFormat() and GetParaFormatL() to get the text object's effective formatting.

A global text object references the two format layers; it does not own them. This allows more than one global text object to use the same formatting. The format layers may be modified (see ApplyParaFormatL() and ApplyCharFormatL()) or replaced (see SetGlobalParaFormat() and SetGlobalCharFormat()) during the text object's lifetime.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CEditableTextAn abstract base class which defines the behaviour that all classes in the editable text class hierarchy (CPlainText, CGlobalText and CRichText) must provide
CGlobalTextText with globally applied formatting
CPlainTextStores and manipulates plain text
MFormatTextSpecifies the mixin protocol for getting and setting character and paragraph format attributes
MLayDocThis class specifies the mixin protocol for providing the information needed by the text layout engine to lay out a text object

Defined in CGlobalText:
ApplyCharFormatL(), ApplyParaFormatL(), CancelSelectLabel(), EnquirePageBreak(), GetCharFormat(), GetChars(), GetParaFormatL(), GetParagraphFormatL(), GetPictureSizeInTwips(), GlobalCharFormatLayer(), GlobalParaFormatLayer(), LdDocumentLength(), LdToParagraphStart(), NewL(), PictureHandleL(), SelectParagraphLabel(), SetGlobalCharFormat(), SetGlobalParaFormat(), ~CGlobalText()

Inherited from CBase:
operator new()

Inherited from CEditableText:
EDefaultTextGranularity, EFlatStorage, ELineBreak, ENonBreakingHyphen, ENonBreakingSpace, ENonBreakingTab, EPageBreak, EParagraphDelimiter, EPictureCharacter, EPotentialHyphen, ESegmentedStorage, ETabCharacter, EVisibleSpaceCharacter, HasChanged(), RestoreL(), SetHasChanged(), StoreL(), TDocumentStorage

Inherited from CPlainText:
Anonymous, CharPosOfParagraph(), ComponentInfo(), ConvertAllFieldsToText(), ConvertFieldToText(), CopyToStoreL(), DeleteL(), DocumentLength(), EOrganiseByLine, EOrganiseByParagraph, EScanBackwards, EScanEndOfData, EScanJoinDelimiters, EScanPictureIsDelimiter, EScanPunctuationIsDelimiter, EScanStayIfBoundary, EScanToUnitEnd, EScanToUnitStart, ExportAsTextL(), ExportTextL(), ExternalizeFieldDataL(), ExternalizeL(), ExternalizePlainTextL(), ExternalizePlainTextNoLengthCountL(), Extract(), FieldCount(), FieldFactory(), FindFields(), GetWordInfo(), ImportTextFileL(), ImportTextL(), InsertFieldL(), InsertL(), InternalizeFieldDataL(), InternalizeL(), InternalizePlainTextL(), NewTextFieldL(), PageContainingPos(), ParagraphCount(), ParagraphNumberForPos(), PasteFromStoreL(), Read(), RemoveField(), Reset(), RestoreComponentsL(), RestoreFieldComponentsL(), ScanParas(), ScanWords(), SetFieldFactory(), SetPageTable(), StoreComponentsL(), StoreFieldComponentsL(), TImportExportParam, TImportExportResult, TScanDataEnd, TTextOrganisation, TextField(), ToParagraphStart(), UpdateAllFieldsL(), UpdateFieldL(), WordCount()

Inherited from MLayDoc:
EForceLoadFalse, EForceLoadTrue, TForcePictureLoad


Construction and destruction


NewL()

static CGlobalText* NewL(const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, TDocumentStorage aStorage=ESegmentedStorage,TInt aDefaultTextGranularity=EDefaultTextGranularity);

Description

Allocates and constructs an empty global text object with a paragraph and a character format layer. A single end-of-document delimiter is inserted.

Parameters

const CParaFormatLayer* aGlobalParaLayer

Pointer to the paragraph format layer referenced by the text object. Must not be NULL, or a panic occurs.

const CCharFormatLayer* aGlobalCharLayer

Pointer to the character format layer referenced by the text object. Must not be NULL, or a panic occurs.

TDocumentStorage aStorage=ESegmentedStorage

The type of in-memory buffer to use. Defaults to ESegmentedStorage.

TInt aDefaultTextGranularity=EDefaultTextGranularity

Specifies the granularity of the in-memory buffer. Default is EDefaultTextGranularity bytes (=256).

Return value

CGlobalText*

Pointer to the global text object.


NewL()

static CGlobalText* NewL(const CStreamStore& aStore,TStreamId aStreamId, const CParaFormatLayer* aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer, MTextFieldFactory* aFieldFactory=NULL, TDocumentStorage=ESegmentedStorage);

Description

Allocates and constructs a new global text object with a paragraph and a character format layer. Its text content and field set are restored from the stream store specified.

Note

If the text object supports fields, a field factory should be specified.

Parameters

const CStreamStore& aStore

Stream store from which the object is restored.

TStreamId aStreamId

ID of the stream store.

const CParaFormatLayer* aGlobalParaLayer

The global paragraph format layer to be referenced by the global text object. Must not be NULL or a panic occurs.

aGlobalParaLayer,const CCharFormatLayer* aGlobalCharLayer

The global character format layer to be referenced by the global text object. Must not be NULL or a panic occurs.

CCharFormatLayer* aGlobalCharLayer, MTextFieldFactory

Pointer to a field factory. A field factory must be provided if the text object supports the addition of fields. Default is NULL.

TDocumentStorage=ESegmentedStorage

The type of in-memory buffer to use. Defaults to ESegmentedStorage.

Return value

CGlobalText*

The new global text object.


~CGlobalText()

~CGlobalText();

Description

The destructor is empty, and is present only to cause the virtual function table to be defined in a unique module.

[Top]


Global format layers


GlobalCharFormatLayer()

const CCharFormatLayer* GlobalCharFormatLayer()const;

Description

Gets the character format layer referenced by the global text object.

Return value

CCharFormatLayer*

Pointer to the character format layer referenced by the global text object.


GlobalParaFormatLayer()

const CParaFormatLayer* GlobalParaFormatLayer()const;

Description

Gets the paragraph format layer referenced by the global text object.

Return value

CParaFormatLayer*

Pointer to the paragraph format layer referenced by the global text object.


SetGlobalCharFormat()

void SetGlobalCharFormat(const CCharFormatLayer* aCharFormatLayer);

Description

Replaces the character format layer referenced by the global text object.

Parameters

const CCharFormatLayer* aCharFormatLayer

Pointer to the character format layer to be referenced by the global text object.


SetGlobalParaFormat()

void SetGlobalParaFormat(const CParaFormatLayer* aParaFormatLayer);

Description

Replaces the paragraph format layer referenced by the global text object.

Parameters

const CParaFormatLayer* aParaFormatLayer

Pointer to the paragraph format layer to be referenced by the global text object.

[Top]


Character and paragraph formatting


GetCharFormat()

virtual void GetCharFormat(TCharFormat& aFormat,TCharFormatMask& aVaries,TInt aPos,TInt aLength)const;

Description

Gets the global text object's effective character formatting. Note that the last three arguments are not relevant to the global text implementation of this function.

Parameters

TCharFormat& aFormat

On return, contains the effective character formatting for the global text object.

TCharFormatMask& aVaries

On return, a bitmask indicating which character format attributes vary over the range of characters selected. This is only relevant for rich text, so for global text returns a value of zero for all attributes.

TInt aPos

This argument is not used for global text.

TInt aLength

This argument is not used for global text.


GetParaFormatL()

virtual void GetParaFormatL(CParaFormat* aFormat,TParaFormatMask& aVaries,TInt aPos,TInt aLength, CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const;

Description

Gets the the global text object's effective paragraph formatting. Note that the position and length arguments are only used in the rich text implementation of this function.

Parameters

CParaFormat* aFormat

Must not be NULL or a panic occurs. On return, contains the effective paragraph formatting for the global text object.

TParaFormatMask& aVaries

On return, a bitmask indicating which paragraph format attributes vary over the range of characters selected. This is only relevant for rich text, so for global text returns a value of zero for all attributes.

TInt aPos

This argument is not used for global text.

TInt aLength

This argument is not used for global text.

CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes

The default, EAllAttributes indicates that values for all paragraph format attributes are written to aFormat. EFixedAttributes indicates that tabs, bullets and borders are not written to aFormat.


ApplyCharFormatL()

virtual void ApplyCharFormatL(const TCharFormat& aFormat,const TCharFormatMask& aMask,TInt aPos,TInt aLength);

Description

Changes the text object's character formatting. The attributes which are set in the mask are read from aFormat into the text object's character format layer. The attributes which are not set in the mask are not changed. Note that the position and length arguments are only used in the rich text implementation of this function.

Parameters

const TCharFormat& aFormat

Contains the character format attribute values to apply.

const TCharFormatMask& aMask

Bitmask specifying the character format attributes to change.

TInt aPos

This argument is not used for global text.

TInt aLength

This argument is not used for global text.


ApplyParaFormatL()

virtual void ApplyParaFormatL(const CParaFormat* aFormat,const TParaFormatMask& aMask,TInt aPos,TInt aLength);

Description

Changes the text object's paragraph formatting. The attributes which are set in the mask are read from aFormat into the text object's paragraph format layer. The attributes which are not set in the mask are not changed. Note that the position and length arguments are only used in the rich text implementation of this function.

Parameters

const CParaFormat* aFormat

Contains the paragraph format attribute values to apply.

const TParaFormatMask& aMask

Bitmask specifying the paragraph format attributes to change.

TInt aPos

This argument is not used for global text.

TInt aLength

This argument is not used for global text.

[Top]


Document enquiry


EnquirePageBreak()

virtual TBool EnquirePageBreak(TInt aPos,TInt aLength=0)const;

Description

Tests whether a page break occurs within a range of characters. Returns false if no page table has been set up: see CPlainText::SetPageTable(). The start and end of the range must be valid document positions, or a panic occurs.

Parameters

TInt aPos

The document position from which to begin searching for a page break.

TInt aLength=0

The number of characters to search for a page break, beginning at aPos. The default is zero.

Return value

TBool

True if a page break occurs within the specified range, otherwise false.


GetChars()

virtual void GetChars(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos)const;

Description

Gets a constant pointer descriptor to a portion of the text object. The portion starts at document position aStartPos, and ends at the end of the document, or the end of the segment, if segmented storage is being used. Also fills a character format object with the text object's effective character formatting. The start position must be valid, or a panic occurs.

Parameters

TPtrC& aView

On return, a constant pointer to a portion of the text.

TCharFormat& aFormat

On return, contains the text object's effective character formatting.

TInt aStartPos

The start position for the view.


GetParagraphFormatL()

virtual void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos)const;

Description

Gets the text object's effective paragraph formatting. The aPos value is only used in the rich text implementation of this function.

Parameters

CParaFormat* aFormat

On return, filled with the text object's effective paragraph formatting.

TInt aPos

This argument is not used for global text.


LdDocumentLength()

virtual TInt LdDocumentLength()const;

Description

Gets the the number of characters in the document.

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

Return value

TInt

The number of characters contained in the document.


LdToParagraphStart()

virtual TInt LdToParagraphStart(TInt& aCurrentPos)const;

Description

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

Parameters

TInt& aCurrentPos

Specifies a document position: must be valid or a panic occurs. On return, specifies the document position of the first character in the paragraph in which it is located.

Return value

TInt

The number of characters skipped in scanning to the start of the paragraph.


GetPictureSizeInTwips()

virtual TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos)const;

Description

Global text provides no support for pictures, so this implementation of the function returns KErrNotFound.


PictureHandleL()

virtual CPicture* PictureHandleL(TInt aPos,MLayDoc::TForcePictureLoad aForceLoad)const;

Description

Global text provides no support for pictures, so this implementation of the function returns NULL.


SelectParagraphLabel()

virtual TBool SelectParagraphLabel(TInt aPos);

Description

Global text does not support paragraph labels, so this function returns EFalse.


CancelSelectLabel()

virtual void CancelSelectLabel();

Description

Not supported.