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