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