1.1 --- a/epoc32/include/txtfmlyr.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/txtfmlyr.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,230 @@
1.4 -txtfmlyr.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __TXTFMLYR_H__
1.21 +#define __TXTFMLYR_H__
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +#include <txtfmstm.h>
1.26 +#include <txtfrmat.h>
1.27 +
1.28 +// forward declarations
1.29 +class CFormatStream;
1.30 +class RReadStream;
1.31 +class RWriteStream;
1.32 +class TCharFormatX;
1.33 +
1.34 +/**
1.35 +@internalTechnology
1.36 +*/
1.37 +const TUid KNormalParagraphStyleUid={268435531};
1.38 +
1.39 +/**
1.40 +Abstract base class for the paragraph and character format layers.
1.41 +
1.42 +A format layer is a set of character or paragraph format attributes which
1.43 +may own a pointer to another format layer. This pointer is called a based-on
1.44 +link. The effective formatting of a text object may be built up from a chain
1.45 +of format layers - the final layer in the chain has a NULL based-on link.
1.46 +In case of conflict, attribute values set in upper layers (layers furthest
1.47 +from the layer with the NULL based-on link) override those set in lower layers.
1.48 +In rich text, additional formatting may be applied on top of these format
1.49 +layers.
1.50 +
1.51 +The system of based-on links is implemented by the CFormatLayer class. It
1.52 +also implements persistence for chains of format layers.
1.53 +
1.54 +When setting or sensing the attributes of a CParaFormatLayer or CCharFormatLayer,
1.55 +a format mask and container are specified as parameters. The container has
1.56 +data members for every format attribute, which may be set independently. When
1.57 +setting the layer, the mask indicates the attributes which will be taken from
1.58 +the container. Any attributes not specified in the mask will be taken from
1.59 +the system-provided default values.
1.60 +
1.61 +When sensing a layer, on return, the mask indicates which attributes have
1.62 +been explicitly set in the layer, (i.e. not taken from the default values).
1.63 +In addition, a layer's effective format may be sensed. In this case, no
1.64 +mask is used because the format container will, on return, contain a value
1.65 +for every attribute.
1.66 +@publishedAll
1.67 +@released
1.68 +*/
1.69 +class CFormatLayer : public CBase
1.70 + {
1.71 +public:
1.72 + //
1.73 + // Based-on link utilities
1.74 + IMPORT_C void Reset(); // Remove all contents of this layer in a leave safe manner.
1.75 + IMPORT_C void SetBase(const CFormatLayer* aBaseFormatLayer); // Set this layer to be based on the specified layer.
1.76 + IMPORT_C const CFormatLayer* SenseBase()const;
1.77 + IMPORT_C TInt ChainCount()const; // Returns the number of format layers in the chain, inclusive of itself.
1.78 + //
1.79 + // Persistence
1.80 +
1.81 +
1.82 + /** Implementations of this function internalise the format layer but not its based-on
1.83 + link from a read stream. The presence of this function means that the standard
1.84 + templated operator>>() (defined in s32strm.h) is available to internalise
1.85 + objects of the derived class. The internalised layer is set to be based on
1.86 + the layer specified.
1.87 +
1.88 + @param aStream Stream from which the format layer should be internalised.
1.89 + @param aBase The based-on link to assign to the layer. By default, NULL. */
1.90 + virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL)=0;
1.91 +
1.92 +
1.93 + /** Implementations of this function externalise the format layer but not its based-on
1.94 + link to a write stream. The presence of this function means that the standard
1.95 + templatedoperator<<() (defined in s32strm.h) is available to externalise objects
1.96 + of the derived class.
1.97 +
1.98 + @param aStream Stream to which the format layer should be externalised. */
1.99 + virtual void ExternalizeL(RWriteStream& aStream)const=0;
1.100 + //
1.101 + // Restore a format chain where the end of the chain is based on aBase (where aBase may be null).
1.102 + IMPORT_C void InternalizeChainL(RReadStream& aStream,const CFormatLayer* aBase=NULL);
1.103 + // Stores a format layer chain of length length-aExcludeCount (or by default the whole chain).
1.104 + IMPORT_C void ExternalizeChainL(RWriteStream& aStream,TInt aExcludeCount=0)const;
1.105 + /** Implementations of this function compare another format layer with the current
1.106 + object. For the two layers to be equal, they must have the same contents and
1.107 + (if the second parameter is ETrue), their based-on links must point to the
1.108 + same format layer.
1.109 +
1.110 + @param aLayer The layer to compare to this format layer.
1.111 + @param aCheckBasedOnLink If ETrue, both layers' based-on links must point to
1.112 + the same format layer. If EFalse, the based-on links are not used in the comparison.
1.113 + By default, ETrue.
1.114 + @return ETrue if the two layers are identical, otherwise EFalse. */
1.115 + virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const=0;
1.116 + IMPORT_C TBool IsEmpty()const;
1.117 + void Swap(CFormatLayer& aLayer);
1.118 +private:
1.119 + CFormatLayer(const CFormatLayer& aFormatLayer);
1.120 + CFormatLayer& operator=(const CFormatLayer& aFormatLayer);
1.121 + virtual CFormatLayer* DoCloneL()const=0;
1.122 +protected:
1.123 + CFormatLayer();
1.124 + ~CFormatLayer();
1.125 + virtual CFormatLayer* RestoreNewL(RReadStream& aStream)=0;
1.126 + void ExternalizeLayersRecurseL(RWriteStream& aStream,TInt aDescendantCount)const;
1.127 + TBool IsIdentical(const TUint8* aPtr,TInt aSize)const;
1.128 + const TUint8* Ptr(TInt& aSize)const;
1.129 + void CloneLayerL(CFormatLayer* aClone)const;
1.130 +protected:
1.131 + RFormatStream iStore;
1.132 + const CFormatLayer* iBasedOn; // If non-null used to inherit format attributes from the lower layer.
1.133 + __DECLARE_TEST;
1.134 + };
1.135 +
1.136 +
1.137 +/**
1.138 +A paragraph format layer.
1.139 +
1.140 +Has a pointer (stored in its base class CFormatLayer) to another paragraph
1.141 +format layer which may be NULL. This pointer is referred to as the based-on
1.142 +link. A paragraph format layer is owned by an instance of the CGlobalText
1.143 +class and stores the object's global paragraph formatting. Implements persistence
1.144 +and allows attributes to be set and sensed.
1.145 +@publishedAll
1.146 +@released
1.147 +*/
1.148 +class CParaFormatLayer : public CFormatLayer
1.149 + {
1.150 +public:
1.151 + IMPORT_C static CParaFormatLayer* NewL();
1.152 + IMPORT_C static CParaFormatLayer* NewL(const CParaFormat* aParaFormat,const TParaFormatMask& aMask);
1.153 + IMPORT_C static CParaFormatLayer* NewL(RReadStream& aStream);
1.154 + static CParaFormatLayer* NewL(const CParaFormatLayer* aLayer);
1.155 + static CParaFormatLayer* NewCopyBaseL(const CParaFormatLayer* aLayer);
1.156 + // Create a new instance, restoring it from the specified stream.
1.157 + // The based on link is NULL. Restores only one layer.
1.158 + //
1.159 + // Persistence
1.160 + IMPORT_C virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL);
1.161 + IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const;
1.162 + //
1.163 + // Core methods
1.164 + IMPORT_C void SetL(const CParaFormat* aDesiredEffectiveFormat,const TParaFormatMask& aMask);
1.165 + IMPORT_C void SenseEffectiveL(CParaFormat* aParaFormat,CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const;
1.166 + IMPORT_C void SenseL(CParaFormat* aParaFormat,TParaFormatMask& aMask,CParaFormat::TParaFormatGetMode aMode=CParaFormat::EAllAttributes)const;
1.167 + //
1.168 + // Utilities
1.169 + inline CParaFormatLayer* CloneL()const;
1.170 + IMPORT_C TBool IsIdenticalL(const CParaFormat* aParaFormat,const TParaFormatMask& aMask)const;
1.171 + IMPORT_C virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const;
1.172 + IMPORT_C virtual TUid Type()const;
1.173 + IMPORT_C const TUint8* Ptr(TInt& aSize)const;
1.174 +private:
1.175 + //
1.176 + // No implementation provided
1.177 + CParaFormatLayer(const CParaFormatLayer& aParaFormatLayer);
1.178 + CParaFormatLayer& operator=(const CParaFormatLayer& aParaFormatLayer);
1.179 + IMPORT_C virtual CFormatLayer* DoCloneL()const;
1.180 + void FillParaFormatL(CParaFormat* aParaFormat,TParaFormatMask& aMask,CParaFormat::TParaFormatGetMode aMode)const;
1.181 + void CleanupEffectiveFormat(CParaFormat* aParaFormat,TParaFormatMask aMask)const;
1.182 + void CleanupBorders(CParaFormat* aParaFormat)const;
1.183 +protected:
1.184 + CParaFormatLayer();
1.185 + virtual CFormatLayer* RestoreNewL(RReadStream& aStream);
1.186 + };
1.187 +
1.188 +/**
1.189 +Character format layer.
1.190 +
1.191 +Uses a pointer (stored in its base class CFormatLayer) to another character
1.192 +format layer which may be NULL. This pointer is referred to as the based-on
1.193 +link. A character format layer is owned by an instance of the CGlobalText
1.194 +class and stores the object's global character formatting. Implements persistence
1.195 +and allows attributes to be set and sensed.
1.196 +@publishedAll
1.197 +@released
1.198 +*/
1.199 +class CCharFormatLayer : public CFormatLayer
1.200 + {
1.201 +public:
1.202 + IMPORT_C static CCharFormatLayer* NewL();
1.203 + IMPORT_C static CCharFormatLayer* NewL(const TCharFormat& aFormat,const TCharFormatMask& aMask);
1.204 + IMPORT_C static CCharFormatLayer* NewL(RReadStream& aStream);
1.205 + IMPORT_C virtual void InternalizeL(RReadStream& aStream,const CFormatLayer* aBase=NULL);
1.206 + IMPORT_C virtual void ExternalizeL(RWriteStream& aStream)const;
1.207 + IMPORT_C void SetL(const TCharFormat& aCharFormat,const TCharFormatMask& aMask);
1.208 + IMPORT_C void SenseEffective(TCharFormat& aCharFormat)const;
1.209 + IMPORT_C void Sense(TCharFormat& aCharFormat,TCharFormatMask& aMask)const;
1.210 + inline CCharFormatLayer* CloneL()const;
1.211 + IMPORT_C virtual TBool IsIdentical(CFormatLayer* aLayer,TBool aCheckBasedOnLink=ETrue)const;
1.212 + IMPORT_C TBool IsIdentical(const TCharFormat& aCharFormat,const TCharFormatMask& aMask)const;
1.213 + IMPORT_C const TUint8* Ptr(TInt& aSize)const;
1.214 +
1.215 + // non-exported public functions
1.216 + static CCharFormatLayer* NewL(const CCharFormatLayer* aLayer);
1.217 + static CCharFormatLayer* NewCopyBaseL(const CCharFormatLayer* aLayer);
1.218 + static CCharFormatLayer* NewL(const TCharFormatX& aFormat,const TCharFormatXMask& aMask);
1.219 + void SetL(const TCharFormatX& aCharFormat,const TCharFormatXMask& aMask);
1.220 + void SenseEffective(TCharFormatX& aCharFormat)const;
1.221 + void Sense(TCharFormatX& aCharFormat,TCharFormatXMask& aMask) const;
1.222 +
1.223 +private:
1.224 + CCharFormatLayer();
1.225 + virtual CFormatLayer* RestoreNewL(RReadStream& aStream);
1.226 + virtual void FillCharFormat(TCharFormatX& aCharFormat,TCharFormatXMask& aMask)const;
1.227 + IMPORT_C virtual CFormatLayer* DoCloneL()const;
1.228 + };
1.229 +
1.230 +
1.231 +#include <txtfmlyr.inl>
1.232 +
1.233 +
1.234 +#endif