epoc32/include/txtfmlyr.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description: 
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@2
    18
williamr@2
    19
#ifndef __TXTFMLYR_H__
williamr@2
    20
#define __TXTFMLYR_H__
williamr@2
    21
williamr@2
    22
#include <e32std.h>
williamr@2
    23
#include <e32base.h>
williamr@2
    24
#include <txtfmstm.h>
williamr@2
    25
#include <txtfrmat.h>
williamr@2
    26
williamr@2
    27
// forward declarations
williamr@2
    28
class CFormatStream;  
williamr@2
    29
class RReadStream;
williamr@2
    30
class RWriteStream;
williamr@2
    31
class TCharFormatX;
williamr@2
    32
williamr@4
    33
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    34
#include <txtfmlyr_internal.h>
williamr@4
    35
#endif
williamr@2
    36
williamr@2
    37
/** 
williamr@2
    38
Abstract base class for the paragraph and character format layers.
williamr@2
    39
williamr@2
    40
A format layer is a set of character or paragraph format attributes which 
williamr@2
    41
may own a pointer to another format layer. This pointer is called a based-on 
williamr@2
    42
link. The effective formatting of a text object may be built up from a chain 
williamr@2
    43
of format layers - the final layer in the chain has a NULL based-on link. 
williamr@2
    44
In case of conflict, attribute values set in upper layers (layers furthest 
williamr@2
    45
from the layer with the NULL based-on link) override those set in lower layers. 
williamr@2
    46
In rich text, additional formatting may be applied on top of these format 
williamr@2
    47
layers.
williamr@2
    48
williamr@2
    49
The system of based-on links is implemented by the CFormatLayer class. It 
williamr@2
    50
also implements persistence for chains of format layers.
williamr@2
    51
williamr@2
    52
When setting or sensing the attributes of a CParaFormatLayer or CCharFormatLayer, 
williamr@2
    53
a format mask and container are specified as parameters. The container has 
williamr@2
    54
data members for every format attribute, which may be set independently. When 
williamr@2
    55
setting the layer, the mask indicates the attributes which will be taken from 
williamr@2
    56
the container. Any attributes not specified in the mask will be taken from 
williamr@2
    57
the system-provided default values.
williamr@2
    58
williamr@2
    59
When sensing a layer, on return, the mask indicates which attributes have 
williamr@2
    60
been explicitly set in the layer, (i.e. not taken from the default values). 
williamr@2
    61
In addition, a layer's effective format may be sensed. In this case, no 
williamr@2
    62
mask is used because the format container will, on return, contain a value 
williamr@2
    63
for every attribute. 
williamr@2
    64
@publishedAll
williamr@2
    65
@released
williamr@2
    66
*/
williamr@2
    67
class CFormatLayer : public CBase
williamr@2
    68
	{
williamr@2
    69
public:
williamr@2
    70
	//
williamr@2
    71
	// Based-on link utilities
williamr@2
    72
	IMPORT_C void Reset();  // Remove all contents of this layer in a leave safe manner.
williamr@2
    73
	IMPORT_C void SetBase(const CFormatLayer* aBaseFormatLayer);  // Set this layer to be based on the specified layer.
williamr@2
    74
	IMPORT_C const CFormatLayer* SenseBase()const;
williamr@2
    75
	IMPORT_C TInt ChainCount()const;  // Returns the number of format layers in the chain, inclusive of itself.
williamr@2
    76
	//
williamr@2
    77
	// Persistence
williamr@2
    78
	
williamr@2
    79
williamr@2
    80
	/** Implementations of this function internalise the format layer but not its based-on 
williamr@2
    81
	link from a read stream. The presence of this function means that the standard 
williamr@2
    82
	templated operator>>() (defined in s32strm.h) is available to internalise 
williamr@2
    83
	objects of the derived class. The internalised layer is set to be based on 
williamr@2
    84
	the layer specified.
williamr@2
    85
	
williamr@2
    86
	@param aStream Stream from which the format layer should be internalised. 
williamr@2
    87
	@param aBase The based-on link to assign to the layer. By default, NULL. */
williamr@2
    88
	virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL)=0;
williamr@2
    89
	
williamr@2
    90
 
williamr@2
    91
	/** Implementations of this function externalise the format layer but not its based-on 
williamr@2
    92
	link to a write stream. The presence of this function means that the standard 
williamr@2
    93
	templatedoperator<<() (defined in s32strm.h) is available to externalise objects 
williamr@2
    94
	of the derived class.
williamr@2
    95
	
williamr@2
    96
	@param aStream Stream to which the format layer should be externalised. */
williamr@2
    97
	virtual void ExternalizeL(RWriteStream& aStream)const=0;
williamr@2
    98
	//
williamr@2
    99
	//	Restore a format chain where the end of the chain is based on aBase (where aBase may be null).
williamr@2
   100
	IMPORT_C void InternalizeChainL(RReadStream& aStream,const CFormatLayer* aBase=NULL);
williamr@2
   101
	//	Stores a format layer chain of length length-aExcludeCount (or by default the whole chain).
williamr@2
   102
	IMPORT_C void ExternalizeChainL(RWriteStream& aStream,TInt aExcludeCount=0)const;
williamr@2
   103
	/** Implementations of this function compare another format layer with the current 
williamr@2
   104
	object. For the two layers to be equal, they must have the same contents and 
williamr@2
   105
	(if the second parameter is ETrue), their based-on links must point to the 
williamr@2
   106
	same format layer.
williamr@2
   107
	
williamr@2
   108
	@param aLayer The layer to compare to this format layer. 
williamr@2
   109
	@param aCheckBasedOnLink If ETrue, both layers' based-on links must point to 
williamr@2
   110
	the same format layer. If EFalse, the based-on links are not used in the comparison. 
williamr@2
   111
	By default, ETrue. 
williamr@2
   112
	@return ETrue if the two layers are identical, otherwise EFalse. */
williamr@2
   113
	virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const=0;
williamr@2
   114
	IMPORT_C TBool IsEmpty()const;
williamr@2
   115
	void Swap(CFormatLayer& aLayer);
williamr@2
   116
private:
williamr@2
   117
	CFormatLayer(const CFormatLayer& aFormatLayer);
williamr@2
   118
	CFormatLayer& operator=(const CFormatLayer& aFormatLayer);
williamr@2
   119
	virtual CFormatLayer* DoCloneL()const=0;
williamr@2
   120
protected:
williamr@2
   121
	CFormatLayer();
williamr@2
   122
	~CFormatLayer();
williamr@2
   123
	virtual CFormatLayer* RestoreNewL(RReadStream& aStream)=0;
williamr@2
   124
	void ExternalizeLayersRecurseL(RWriteStream& aStream,TInt aDescendantCount)const;
williamr@2
   125
	TBool IsIdentical(const TUint8* aPtr,TInt aSize)const;
williamr@2
   126
	const TUint8* Ptr(TInt& aSize)const;
williamr@2
   127
	void CloneLayerL(CFormatLayer* aClone)const;
williamr@2
   128
protected:
williamr@2
   129
	RFormatStream iStore;
williamr@2
   130
	const CFormatLayer* iBasedOn;  // If non-null used to inherit format attributes from the lower layer.
williamr@2
   131
	__DECLARE_TEST;
williamr@2
   132
	};
williamr@2
   133
williamr@2
   134
williamr@2
   135
/** 
williamr@2
   136
A paragraph format layer. 
williamr@2
   137
williamr@2
   138
Has a pointer (stored in its base class CFormatLayer) to another paragraph 
williamr@2
   139
format layer which may be NULL. This pointer is referred to as the based-on 
williamr@2
   140
link. A paragraph format layer is owned by an instance of the CGlobalText 
williamr@2
   141
class and stores the object's global paragraph formatting. Implements persistence 
williamr@2
   142
and allows attributes to be set and sensed. 
williamr@2
   143
@publishedAll
williamr@2
   144
@released
williamr@2
   145
*/
williamr@2
   146
class CParaFormatLayer : public CFormatLayer
williamr@2
   147
	{
williamr@2
   148
public:
williamr@2
   149
	IMPORT_C static CParaFormatLayer* NewL();
williamr@2
   150
	IMPORT_C static CParaFormatLayer* NewL(const CParaFormat* aParaFormat,const TParaFormatMask& aMask);
williamr@2
   151
	IMPORT_C static CParaFormatLayer* NewL(RReadStream& aStream);
williamr@2
   152
	static CParaFormatLayer* NewL(const CParaFormatLayer* aLayer);
williamr@2
   153
	static CParaFormatLayer* NewCopyBaseL(const CParaFormatLayer* aLayer);
williamr@2
   154
	// Create a new instance, restoring it from the specified stream.
williamr@2
   155
	// The based on link is NULL. Restores only one layer.
williamr@2
   156
	//
williamr@2
   157
	// Persistence
williamr@2
   158
	IMPORT_C virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL);	
williamr@2
   159
	IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const;
williamr@2
   160
	//
williamr@2
   161
	// Core methods
williamr@2
   162
	IMPORT_C void SetL(const CParaFormat* aDesiredEffectiveFormat,const TParaFormatMask& aMask);
williamr@2
   163
	IMPORT_C void SenseEffectiveL(CParaFormat* aParaFormat,CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const;
williamr@2
   164
	IMPORT_C void SenseL(CParaFormat* aParaFormat,TParaFormatMask& aMask,CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const;
williamr@2
   165
	//
williamr@2
   166
	// Utilities
williamr@2
   167
	inline CParaFormatLayer* CloneL()const;
williamr@2
   168
	IMPORT_C TBool IsIdenticalL(const CParaFormat* aParaFormat,const TParaFormatMask& aMask)const;
williamr@2
   169
	IMPORT_C virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const;
williamr@2
   170
	IMPORT_C virtual TUid Type()const;
williamr@2
   171
	IMPORT_C const TUint8* Ptr(TInt& aSize)const;
williamr@2
   172
private:
williamr@2
   173
	//
williamr@2
   174
	// No implementation provided
williamr@2
   175
	CParaFormatLayer(const CParaFormatLayer& aParaFormatLayer);
williamr@2
   176
	CParaFormatLayer& operator=(const CParaFormatLayer& aParaFormatLayer);
williamr@2
   177
	IMPORT_C virtual CFormatLayer* DoCloneL()const;
williamr@2
   178
	void FillParaFormatL(CParaFormat* aParaFormat,TParaFormatMask& aMask,CParaFormat::TParaFormatGetMode aMode)const;
williamr@2
   179
	void CleanupEffectiveFormat(CParaFormat* aParaFormat,TParaFormatMask aMask)const;
williamr@2
   180
	void CleanupBorders(CParaFormat* aParaFormat)const;
williamr@2
   181
protected:
williamr@2
   182
	CParaFormatLayer();
williamr@2
   183
	virtual CFormatLayer* RestoreNewL(RReadStream& aStream);
williamr@2
   184
	};
williamr@2
   185
williamr@2
   186
/** 
williamr@2
   187
Character format layer.
williamr@2
   188
williamr@2
   189
Uses a pointer (stored in its base class CFormatLayer) to another character 
williamr@2
   190
format layer which may be NULL. This pointer is referred to as the based-on 
williamr@2
   191
link. A character format layer is owned by an instance of the CGlobalText 
williamr@2
   192
class and stores the object's global character formatting. Implements persistence 
williamr@2
   193
and allows attributes to be set and sensed. 
williamr@2
   194
@publishedAll
williamr@2
   195
@released
williamr@2
   196
*/
williamr@2
   197
class CCharFormatLayer : public CFormatLayer
williamr@2
   198
	{
williamr@2
   199
public:
williamr@2
   200
	IMPORT_C static CCharFormatLayer* NewL();
williamr@2
   201
	IMPORT_C static CCharFormatLayer* NewL(const TCharFormat& aFormat,const TCharFormatMask& aMask);
williamr@2
   202
	IMPORT_C static CCharFormatLayer* NewL(RReadStream& aStream);
williamr@2
   203
	IMPORT_C virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL);	
williamr@2
   204
	IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const;
williamr@2
   205
	IMPORT_C void SetL(const TCharFormat& aCharFormat,const TCharFormatMask& aMask);
williamr@2
   206
	IMPORT_C void SenseEffective(TCharFormat& aCharFormat)const;
williamr@2
   207
	IMPORT_C void Sense(TCharFormat& aCharFormat,TCharFormatMask& aMask)const;
williamr@2
   208
	inline CCharFormatLayer* CloneL()const;
williamr@2
   209
	IMPORT_C virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const;
williamr@2
   210
	IMPORT_C TBool IsIdentical(const TCharFormat& aCharFormat,const TCharFormatMask& aMask)const;
williamr@2
   211
	IMPORT_C const TUint8* Ptr(TInt& aSize)const;
williamr@2
   212
williamr@2
   213
	// non-exported public functions
williamr@2
   214
	static CCharFormatLayer* NewL(const CCharFormatLayer* aLayer);
williamr@2
   215
	static CCharFormatLayer* NewCopyBaseL(const CCharFormatLayer* aLayer);
williamr@2
   216
	static CCharFormatLayer* NewL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask);
williamr@2
   217
	void SetL(const TCharFormatX& aCharFormat,const TCharFormatXMask& aMask);
williamr@2
   218
	void SenseEffective(TCharFormatX& aCharFormat)const;
williamr@2
   219
	void Sense(TCharFormatX& aCharFormat,TCharFormatXMask& aMask) const;
williamr@2
   220
	
williamr@2
   221
private:
williamr@2
   222
	CCharFormatLayer();
williamr@2
   223
	virtual CFormatLayer* RestoreNewL(RReadStream& aStream);
williamr@2
   224
	virtual void FillCharFormat(TCharFormatX& aCharFormat,TCharFormatXMask& aMask)const;
williamr@2
   225
	IMPORT_C virtual CFormatLayer* DoCloneL()const;
williamr@2
   226
	};
williamr@2
   227
williamr@2
   228
williamr@2
   229
#include <txtfmlyr.inl>
williamr@2
   230
williamr@2
   231
williamr@2
   232
#endif