Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: TXTSTYLE.H
Link against: etext.lib

Class CStyleList

class CStyleList : public CBase;

Description

A container of paragraph styles.

It is implemented as a fixed length array of pointers to RParagraphStyleInfos. The array's granularity is specified on construction. The list takes ownership of all paragraph styles appended to it. When the list is deleted, all styles it owns are also deleted.

After the style list has been set up, it should normally be passed to a CRichText object, either in the rich text object's constructor, or by calling CRichText::SetStyleListExternallyOwned(). The rich text object takes ownership of the style list (unless SetStyleListExternallyOwned() is used). Styles can be modified, added to and removed from the style list after ownership of the list has been passed to the rich text object.

If CRichText::SetStyleListExternallyOwned() is used, the style list is not owned by the rich text object, and it must be stored and restored separately from the rich text object.

Derivation

Members

Defined in CStyleList:
AppendL(), At(), At(), CStyleList(), ConstructL(), Count(), DeepCloneL(), ExternalizeL(), IndexByName(), IndexByPtr(), InternalizeL(), NewL(), NewL(), PtrByName(), PtrByType(), Remove(), Reset(), SetStyleToFollow(), StoreL(), operator[](), operator[](), ~CStyleList()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


NewL()

static IMPORT_C CStyleList *NewL(TInt aCapacity=KMaxStyleListGranularity);

Description

Allocates and constructs an empty CStyleList object with an array granularity.

Parameters

TInt aCapacity

The number of entries by which the array of styles expands when its buffer is reallocated. By default, KMaxStyleListGranularity (= 4). Must be positive or a panic occurs.

Return value

CStyleList *

Pointer to the new style list.


NewL()

static IMPORT_C CStyleList *NewL(RReadStream &aStream, const CParaFormatLayer *aGlobalParaFormatLayer, const CCharFormatLayer *aGlobalCharFormatLayer);

Description

Allocates and constructs a CStyleList, restoring its contents from the specified stream store. Each style in the list is set to be based on the global format layers specified.

Parameters

RReadStream &aStream

Stream store from which the style list is restored.

const CParaFormatLayer *aGlobalParaFormatLayer

Pointer to the global paragraph format layer on which all styles in the list are based.

const CCharFormatLayer *aGlobalCharFormatLayer

Pointer to the global character format layer on which all styles in the list are based.

Return value

CStyleList *

Pointer to the new style list.


~CStyleList()

IMPORT_C ~CStyleList();

Description

Deletes all the entries in the list and the list itself.


CStyleList()

protected: IMPORT_C CStyleList();

Description


ConstructL()

protected: IMPORT_C void ConstructL(TInt aGranularity);

Description

Parameters

TInt aGranularity

[Top]


Member functions


operator[]()

inline const RParagraphStyleInfo &operator[](TInt aIndex) const;

Description

Gets a style from the style list, from its index into the array. Two versions are supplied. The compiler chooses the appropriate version based on the use made of the returned reference. If it is used in an expression where the reference can be modified, then the non-const version is chosen.

Parameters

TInt aIndex

The index of the style into the list. The first style is at position zero. Must be within the bounds of the array or a panic occurs.

Return value

const RParagraphStyleInfo &

A const reference to the style at position aIndex in the array. A non-const reference to the style at position aIndex in the array.


operator[]()

inline RParagraphStyleInfo &operator[](TInt aIndex);

Description

Parameters

TInt aIndex

Return value

RParagraphStyleInfo &


At()

IMPORT_C const RParagraphStyleInfo &At(TInt aIndex) const;

Description

Gets a style from the style list, from its index into the array. Two versions are supplied. The compiler chooses the appropriate version based on the use made of the returned reference. If it is used in an expression where that reference can be modified, then the non-const version is chosen.

Parameters

TInt aIndex

The index of the style into the list. The first style is at position zero. Must be within the bounds of the array, or a panic occurs.

Return value

const RParagraphStyleInfo &

A const reference to the style at position aIndex in the array. A non-const reference to the style at position aIndex in the array.


At()

IMPORT_C RParagraphStyleInfo &At(TInt aIndex);

Description

Parameters

TInt aIndex

Return value

RParagraphStyleInfo &


StoreL()

IMPORT_C TStreamId StoreL(CStreamStore &aStore) const;

Description

Stores the style list to a stream store.

Parameters

CStreamStore &aStore

Stream store to which the style list is written.

Return value

TStreamId

The ID of the stream store.


ExternalizeL()

IMPORT_C void ExternalizeL(RWriteStream &aStream) const;

Description

Externalises the style list 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. Does not externalise any styles' based-on links.

Parameters

RWriteStream &aStream

Stream to which the object should be externalised.


InternalizeL()

IMPORT_C void InternalizeL(RReadStream &aStream, const CParaFormatLayer *aGlobalParaFormatLayer, const CCharFormatLayer *aGlobalCharFormatLayer);

Description

Internalises the style list 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. Any existing style list contents are replaced.

Parameters

RReadStream &aStream

Stream store from which the style list is internalised.

const CParaFormatLayer *aGlobalParaFormatLayer

Pointer to the global paragraph format layer on which all styles in the list are based.

const CCharFormatLayer *aGlobalCharFormatLayer

Pointer to the global character format layer on which all styles in the list are based.


Reset()

IMPORT_C void Reset();

Description

Deletes the contents of the list.


AppendL()

IMPORT_C TInt AppendL(RParagraphStyleInfo *aStyleSet);

Description

Appends a style to the style list. The list takes ownership of the style.

Parameters

RParagraphStyleInfo *aStyleSet

The style (and optional style for the following paragraph) to append to the list.

Return value

TInt

KErrNone if successful, or KErrAlreadyExists if the style is already present in the list.


Remove()

IMPORT_C void Remove(CParagraphStyle *aStyle);

Description

Removes a style from the style list. If the style is owned by the list, it is deleted. If the style is not owned by the list, but is referenced by a style owned by the list, (i.e. a style in the list is based on it, or references it as its iStyleForNextPara pointer) then the pointer to aStyle is set to NULL.

Parameters

CParagraphStyle *aStyle

Pointer to the style to remove from the style list, or to set to NULL.


SetStyleToFollow()

IMPORT_C TInt SetStyleToFollow(const RParagraphStyleInfo &aStyleSet);

Description

Sets the style to use for the following paragraph for a style in the style list. Both the style (aStyleSet.iStyle) and the style to set for the following paragraph (aStyleSet.iStyleForNextPara) must exist in the style list.

The function first locates the style (aStyleSet.iStyle) in the list, then sets the style to use for the next paragraph to aStyleSet.iStyleForNextPara.

If aStyleSet.iStyle does not exist in the style list, the function returns with KErrNotFound. If aStyleSet.iStyleForNextPara does not exist in the style list, a panic occurs.

Parameters

const RParagraphStyleInfo &aStyleSet

Identifies a style in the list, and a style to use for its following paragraph.

Return value

TInt

KErrNone if successful, or KErrNotFound if the first style contained in the argument (aStyleSet.iStyle) is not in the style list.


DeepCloneL()

IMPORT_C CStyleList *DeepCloneL() const;

Description

Creates and returns a style list which is a clone of the current style list.

Return value

CStyleList *

Pointer to a clone of the current style list.


PtrByName()

IMPORT_C RParagraphStyleInfo *PtrByName(const TParagraphStyleName &aName) const;

Description

Gets the style with the specified name from the style list.

Parameters

const TParagraphStyleName &aName

The name of the style to retrieve.

Return value

RParagraphStyleInfo *

Pointer to the style with the name specified. NULL if there is no style with this name in the list.


PtrByType()

IMPORT_C RParagraphStyleInfo *PtrByType(const TUid aType) const;

Description

Gets the style with the specified type UID from the style list.

Parameters

const TUid aType

The UID of the style to retrieve.

Return value

RParagraphStyleInfo *

Pointer to the style with the type UID specified. NULL if there is no style with this type in the list.


IndexByPtr()

IMPORT_C TInt IndexByPtr(const CParaFormatLayer *aPtr) const;

Description

Gets the index into the style list of a specified paragraph style.

Parameters

const CParaFormatLayer *aPtr

Pointer to the style.

Return value

TInt

The style's index into the style list. KErrNotFound if the style is not found in the style list, or if aPtr is a paragraph format layer rather than a style.


IndexByName()

IMPORT_C TInt IndexByName(const TDesC &aName) const;

Description

Gets the index into the style list of a specified paragraph style, identified by its name.

Parameters

const TDesC &aName

The name of the style.

Return value

TInt

The style's index into the style list. KErrNotFound if the style name is not found in the style list.


Count()

inline TInt Count() const;

Description

Gets the number of styles in the style list.

Return value

TInt

The number of styles in the style list