sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <gdi.h>
|
sl@0
|
23 |
#include "TXTFRMAT.H"
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "TXTSTD.H"
|
sl@0
|
26 |
#include "OstTraceDefinitions.h"
|
sl@0
|
27 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
sl@0
|
28 |
#include "TXTFRMATTraces.h"
|
sl@0
|
29 |
#endif
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
const TInt KParaDefaultLanguage=0;
|
sl@0
|
34 |
const TInt KParaDefaultLeftMargin=0;
|
sl@0
|
35 |
const TInt KParaDefaultRightMargin=0;
|
sl@0
|
36 |
const TInt KParaDefaultIndent=0;
|
sl@0
|
37 |
const CParaFormat::TAlignment KParaDefaultHorizAlign=CParaFormat::ELeftAlign;
|
sl@0
|
38 |
const CParaFormat::TAlignment KParaDefaultVertAlign=CParaFormat::EUnspecifiedAlign;
|
sl@0
|
39 |
const TInt KParaDefaultLineSpacing=200; // 200 twips = 10pt
|
sl@0
|
40 |
const CParaFormat::TLineSpacingControl KParaDefaultLineSpacingControl=CParaFormat::ELineSpacingAtLeastInTwips;
|
sl@0
|
41 |
const TInt KParaDefaultSpaceBefore=0;
|
sl@0
|
42 |
const TInt KParaDefaultSpaceAfter=0;
|
sl@0
|
43 |
const TBool KParaDefaultKeepTogether=EFalse;
|
sl@0
|
44 |
const TBool KParaDefaultKeepWithNext=EFalse;
|
sl@0
|
45 |
const TBool KParaDefaultStartNewPage=EFalse;
|
sl@0
|
46 |
const TBool KParaDefaultWidowOrphan=EFalse;
|
sl@0
|
47 |
const TBool KParaDefaultWrap=ETrue;
|
sl@0
|
48 |
const TInt KParaDefaultBorderMargin=0;
|
sl@0
|
49 |
const TInt KParaDefaultTabWidth=360; // 360 twips = 0.25"
|
sl@0
|
50 |
const TUint KParFormatBits = (2 << EAttTabStop) - 1;
|
sl@0
|
51 |
const TUint KCharFormatBits = (2 << (EAttFontHiddenText - EAttCharLanguage)) - 1;
|
sl@0
|
52 |
|
sl@0
|
53 |
|
sl@0
|
54 |
EXPORT_C TTabStop::TTabStop():
|
sl@0
|
55 |
iTwipsPosition(0),
|
sl@0
|
56 |
iType(ELeftTab)
|
sl@0
|
57 |
/** The default C++ constructor constructs a TTabStop. The twips position is
|
sl@0
|
58 |
initialised to zero and the alignment to ELeftTab. */
|
sl@0
|
59 |
{
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
EXPORT_C TTabStop::TTabStop(const TTabStop& aTabStop):
|
sl@0
|
63 |
iTwipsPosition(aTabStop.iTwipsPosition),
|
sl@0
|
64 |
iType(aTabStop.iType)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
EXPORT_C TTabStop& TTabStop::operator=(const TTabStop& aTabStop)
|
sl@0
|
69 |
/** Assigns the twips position and alignment of aTabStop to the current TTabStop.
|
sl@0
|
70 |
|
sl@0
|
71 |
@param aTabStop The tab stop to assign to the current tab stop.
|
sl@0
|
72 |
@return The current tab stop. */
|
sl@0
|
73 |
{
|
sl@0
|
74 |
iTwipsPosition=aTabStop.iTwipsPosition;
|
sl@0
|
75 |
iType=aTabStop.iType;
|
sl@0
|
76 |
return *this;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
EXPORT_C TBool TTabStop::operator==(const TTabStop& aTabStop)const
|
sl@0
|
80 |
/** Compares two tab stops for equality. To be equal, they must have the same
|
sl@0
|
81 |
twips position and alignment.
|
sl@0
|
82 |
|
sl@0
|
83 |
@param aTabStop The tab stop to compare with the current tab stop.
|
sl@0
|
84 |
@return ETrue if both tab stops have the same twips position and alignment.
|
sl@0
|
85 |
EFalse if not. */
|
sl@0
|
86 |
{
|
sl@0
|
87 |
if (iTwipsPosition!=aTabStop.iTwipsPosition)
|
sl@0
|
88 |
return EFalse;
|
sl@0
|
89 |
if (iType!=aTabStop.iType)
|
sl@0
|
90 |
return EFalse;
|
sl@0
|
91 |
return ETrue;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
EXPORT_C TParaBorder::TParaBorder():
|
sl@0
|
95 |
iLineStyle(ENullLineStyle),
|
sl@0
|
96 |
iThickness(0),
|
sl@0
|
97 |
iColor(TLogicalRgb::ESystemForegroundColor),
|
sl@0
|
98 |
iAutoColor(ETrue)
|
sl@0
|
99 |
/** The default C++ constructor constructs a TParaBorder, initializing its line
|
sl@0
|
100 |
style to ENullLineStyle, its line thickness to zero, its colour to KRgbBlack
|
sl@0
|
101 |
and iAutocolor to ETrue. */
|
sl@0
|
102 |
{
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
EXPORT_C TBool TParaBorder::operator==(const TParaBorder& aParaBorder)const
|
sl@0
|
106 |
/** Compares two paragraph border sides for equality. For two paragraph border
|
sl@0
|
107 |
sides to be equal, all data members must be equal.
|
sl@0
|
108 |
|
sl@0
|
109 |
@param aBorder The paragraph border to compare with the current border.
|
sl@0
|
110 |
@return ETrue if the two paragraph border sides are equal, EFalse if not. */
|
sl@0
|
111 |
{
|
sl@0
|
112 |
if (iLineStyle!=aParaBorder.iLineStyle)
|
sl@0
|
113 |
return EFalse;
|
sl@0
|
114 |
if (iThickness!=aParaBorder.iThickness)
|
sl@0
|
115 |
return EFalse;
|
sl@0
|
116 |
if (iColor!=aParaBorder.iColor)
|
sl@0
|
117 |
return EFalse;
|
sl@0
|
118 |
if (iAutoColor!=aParaBorder.iAutoColor)
|
sl@0
|
119 |
return EFalse;
|
sl@0
|
120 |
return ETrue;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
EXPORT_C TBullet::TBullet():
|
sl@0
|
124 |
iCharacterCode(0x2022),
|
sl@0
|
125 |
iHeightInTwips(0),
|
sl@0
|
126 |
iHangingIndent(TRUE),
|
sl@0
|
127 |
iColor(TLogicalRgb::ESystemForegroundColor),
|
sl@0
|
128 |
iStyle(EBulletStyle),
|
sl@0
|
129 |
iStartNumber(1),
|
sl@0
|
130 |
iAlignment(ELeftAlign)
|
sl@0
|
131 |
/** The default C++ constructor constructs a TBullet, initializing the
|
sl@0
|
132 |
character code to 0x2022, the height to zero, the colour to the system's
|
sl@0
|
133 |
default foreground colour and the hanging indent to ETrue. The typeface
|
sl@0
|
134 |
is not initialised. */
|
sl@0
|
135 |
{
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
EXPORT_C TBool TBullet::operator==(const TBullet& aBullet)const
|
sl@0
|
139 |
/** Compares two bullet points for equality. For two bullet points to be equal,
|
sl@0
|
140 |
all data members must be equal.
|
sl@0
|
141 |
|
sl@0
|
142 |
@param aBullet The bullet point to compare.
|
sl@0
|
143 |
@return ETrue if the two bullet points are equal, EFalse if not. */
|
sl@0
|
144 |
{
|
sl@0
|
145 |
return iCharacterCode == aBullet.iCharacterCode &&
|
sl@0
|
146 |
iHeightInTwips == aBullet.iHeightInTwips &&
|
sl@0
|
147 |
iHangingIndent == aBullet.iHangingIndent &&
|
sl@0
|
148 |
iColor == aBullet.iColor &&
|
sl@0
|
149 |
iStyle == aBullet.iStyle &&
|
sl@0
|
150 |
iStartNumber == aBullet.iStartNumber &&
|
sl@0
|
151 |
iAlignment == aBullet.iAlignment &&
|
sl@0
|
152 |
iTypeface == aBullet.iTypeface;
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
EXPORT_C CParaFormat* CParaFormat::NewL()
|
sl@0
|
156 |
/** Allocates and constructs a CParaFormat object. All attributes are
|
sl@0
|
157 |
initialised with default values.
|
sl@0
|
158 |
|
sl@0
|
159 |
@return The new CParaFormat object. */
|
sl@0
|
160 |
{
|
sl@0
|
161 |
return new(ELeave) CParaFormat;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
EXPORT_C CParaFormat* CParaFormat::NewLC()
|
sl@0
|
165 |
/** Allocates and constructs a CParaFormat object. All attributes are
|
sl@0
|
166 |
initialised with default values. Leaves the object on the cleanup stack.
|
sl@0
|
167 |
|
sl@0
|
168 |
@return The new CParaFormat object. */
|
sl@0
|
169 |
{
|
sl@0
|
170 |
CParaFormat* self=new(ELeave) CParaFormat;
|
sl@0
|
171 |
CleanupStack::PushL(self);
|
sl@0
|
172 |
return self;
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
EXPORT_C CParaFormat* CParaFormat::NewL(const CParaFormat& aFormat)
|
sl@0
|
176 |
/** Allocates and constructs a new CParaFormat. All attributes are initialised
|
sl@0
|
177 |
to the values contained in the aFormat argument.
|
sl@0
|
178 |
|
sl@0
|
179 |
@param aFormat Paragraph format container whose values are used to initialise
|
sl@0
|
180 |
the new CParaFormat.
|
sl@0
|
181 |
@return The new CParaFormat object. */
|
sl@0
|
182 |
{
|
sl@0
|
183 |
CParaFormat* self = new(ELeave) CParaFormat(aFormat);
|
sl@0
|
184 |
CleanupStack::PushL(self);
|
sl@0
|
185 |
self->CopyL(aFormat);
|
sl@0
|
186 |
CleanupStack::Pop();
|
sl@0
|
187 |
return self;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
EXPORT_C CParaFormat::CParaFormat():
|
sl@0
|
191 |
iTabList(NULL),
|
sl@0
|
192 |
iParaBorderArray(NULL),
|
sl@0
|
193 |
iFillColor(TLogicalRgb::ESystemBackgroundColor),
|
sl@0
|
194 |
iLanguage(KParaDefaultLanguage),
|
sl@0
|
195 |
iLeftMarginInTwips(KParaDefaultLeftMargin),
|
sl@0
|
196 |
iRightMarginInTwips(KParaDefaultRightMargin),
|
sl@0
|
197 |
iIndentInTwips(KParaDefaultIndent),
|
sl@0
|
198 |
iHorizontalAlignment(KParaDefaultHorizAlign),
|
sl@0
|
199 |
iVerticalAlignment(KParaDefaultVertAlign),
|
sl@0
|
200 |
iLineSpacingInTwips(KParaDefaultLineSpacing),
|
sl@0
|
201 |
iLineSpacingControl(KParaDefaultLineSpacingControl),
|
sl@0
|
202 |
iSpaceBeforeInTwips(KParaDefaultSpaceBefore),
|
sl@0
|
203 |
iSpaceAfterInTwips(KParaDefaultSpaceAfter),
|
sl@0
|
204 |
iKeepTogether(KParaDefaultKeepTogether),
|
sl@0
|
205 |
iKeepWithNext(KParaDefaultKeepWithNext),
|
sl@0
|
206 |
iStartNewPage(KParaDefaultStartNewPage),
|
sl@0
|
207 |
iWidowOrphan(KParaDefaultWidowOrphan),
|
sl@0
|
208 |
iWrap(KParaDefaultWrap),
|
sl@0
|
209 |
iBorderMarginInTwips(KParaDefaultBorderMargin),
|
sl@0
|
210 |
iBullet(NULL),
|
sl@0
|
211 |
iDefaultTabWidthInTwips(KParaDefaultTabWidth)
|
sl@0
|
212 |
/** The default C++ constructor constructs a new CParaFormat initialising all
|
sl@0
|
213 |
attributes to the default settings.
|
sl@0
|
214 |
|
sl@0
|
215 |
Note: This function allows a CParaFormat object to be created on the stack. This
|
sl@0
|
216 |
should only be done if it is known in advance that the object will not be
|
sl@0
|
217 |
used to store tab stops, bullets or borders. */
|
sl@0
|
218 |
{
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
|
sl@0
|
222 |
CParaFormat::CParaFormat(const CParaFormat& aFormat):
|
sl@0
|
223 |
iFillColor(aFormat.iFillColor),
|
sl@0
|
224 |
iLanguage(aFormat.iLanguage),
|
sl@0
|
225 |
iLeftMarginInTwips(aFormat.iLeftMarginInTwips),
|
sl@0
|
226 |
iRightMarginInTwips(aFormat.iRightMarginInTwips),
|
sl@0
|
227 |
iIndentInTwips(aFormat.iIndentInTwips),
|
sl@0
|
228 |
iHorizontalAlignment(aFormat.iHorizontalAlignment),
|
sl@0
|
229 |
iVerticalAlignment(aFormat.iVerticalAlignment),
|
sl@0
|
230 |
iLineSpacingInTwips(aFormat.iLineSpacingInTwips),
|
sl@0
|
231 |
iLineSpacingControl(aFormat.iLineSpacingControl),
|
sl@0
|
232 |
iSpaceBeforeInTwips(aFormat.iSpaceBeforeInTwips),
|
sl@0
|
233 |
iSpaceAfterInTwips(aFormat.iSpaceAfterInTwips),
|
sl@0
|
234 |
iKeepTogether(aFormat.iKeepTogether),
|
sl@0
|
235 |
iKeepWithNext(aFormat.iKeepWithNext),
|
sl@0
|
236 |
iStartNewPage(aFormat.iStartNewPage),
|
sl@0
|
237 |
iWidowOrphan(aFormat.iWidowOrphan),
|
sl@0
|
238 |
iWrap(aFormat.iWrap),
|
sl@0
|
239 |
iBorderMarginInTwips(aFormat.iBorderMarginInTwips),
|
sl@0
|
240 |
iDefaultTabWidthInTwips(aFormat.iDefaultTabWidthInTwips)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
void CParaFormat::CreateTabListL()
|
sl@0
|
245 |
{
|
sl@0
|
246 |
if (!iTabList)
|
sl@0
|
247 |
iTabList = new(ELeave) CArrayFixFlat<TTabStop>(ETabStoreGranularity);
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
EXPORT_C CParaFormat::~CParaFormat()
|
sl@0
|
251 |
/** The destructor frees all resources owned by the paragraph format container
|
sl@0
|
252 |
(tabs, borders and bullets), prior to its destruction.
|
sl@0
|
253 |
|
sl@0
|
254 |
Note that Strip() also sets the resource pointers to NULL. This is important
|
sl@0
|
255 |
in case CParaFormat is on the stack and gets deleted twice: once by the cleanup
|
sl@0
|
256 |
stack and once by exceptions being unwound. */
|
sl@0
|
257 |
{
|
sl@0
|
258 |
Strip();
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
EXPORT_C void CParaFormat::CopyL(const CParaFormat& aFormat)
|
sl@0
|
262 |
/** Copies all attribute values from another paragraph format container.
|
sl@0
|
263 |
|
sl@0
|
264 |
@param aFormat Contains the attribute values to copy. */
|
sl@0
|
265 |
{
|
sl@0
|
266 |
TParaFormatMask mask;
|
sl@0
|
267 |
mask.SetAll();
|
sl@0
|
268 |
CopyL(aFormat,mask);
|
sl@0
|
269 |
}
|
sl@0
|
270 |
|
sl@0
|
271 |
EXPORT_C void CParaFormat::CopyL(const CParaFormat& aFormat,const TParaFormatMask& aMask)
|
sl@0
|
272 |
/** Copies selected attribute values from another paragraph format container.
|
sl@0
|
273 |
Only the attributes which are set in the mask are copied.
|
sl@0
|
274 |
|
sl@0
|
275 |
@param aFormat Contains the attribute values to copy.
|
sl@0
|
276 |
@param aMask Bitmask specifying the attributes to copy. */
|
sl@0
|
277 |
{
|
sl@0
|
278 |
if (aMask.AttribIsSet(EAttParaLanguage))
|
sl@0
|
279 |
iLanguage=aFormat.iLanguage;
|
sl@0
|
280 |
if (aMask.AttribIsSet(EAttFillColor))
|
sl@0
|
281 |
iFillColor=aFormat.iFillColor;
|
sl@0
|
282 |
if (aMask.AttribIsSet(EAttLeftMargin))
|
sl@0
|
283 |
iLeftMarginInTwips=aFormat.iLeftMarginInTwips;
|
sl@0
|
284 |
if (aMask.AttribIsSet(EAttRightMargin))
|
sl@0
|
285 |
iRightMarginInTwips=aFormat.iRightMarginInTwips;
|
sl@0
|
286 |
if (aMask.AttribIsSet(EAttIndent))
|
sl@0
|
287 |
iIndentInTwips=aFormat.iIndentInTwips;
|
sl@0
|
288 |
if (aMask.AttribIsSet(EAttAlignment))
|
sl@0
|
289 |
iHorizontalAlignment=aFormat.iHorizontalAlignment;
|
sl@0
|
290 |
if (aMask.AttribIsSet(EAttVerticalAlignment))
|
sl@0
|
291 |
iVerticalAlignment=aFormat.iVerticalAlignment;
|
sl@0
|
292 |
if (aMask.AttribIsSet(EAttLineSpacing))
|
sl@0
|
293 |
iLineSpacingInTwips=aFormat.iLineSpacingInTwips;
|
sl@0
|
294 |
if (aMask.AttribIsSet(EAttLineSpacingControl))
|
sl@0
|
295 |
iLineSpacingControl=aFormat.iLineSpacingControl;
|
sl@0
|
296 |
if (aMask.AttribIsSet(EAttSpaceBefore))
|
sl@0
|
297 |
iSpaceBeforeInTwips=aFormat.iSpaceBeforeInTwips;
|
sl@0
|
298 |
if (aMask.AttribIsSet(EAttSpaceAfter))
|
sl@0
|
299 |
iSpaceAfterInTwips=aFormat.iSpaceAfterInTwips;
|
sl@0
|
300 |
if (aMask.AttribIsSet(EAttKeepTogether))
|
sl@0
|
301 |
iKeepTogether=aFormat.iKeepTogether;
|
sl@0
|
302 |
if (aMask.AttribIsSet(EAttKeepWithNext))
|
sl@0
|
303 |
iKeepWithNext=aFormat.iKeepWithNext;
|
sl@0
|
304 |
if (aMask.AttribIsSet(EAttStartNewPage))
|
sl@0
|
305 |
iStartNewPage=aFormat.iStartNewPage;
|
sl@0
|
306 |
if (aMask.AttribIsSet(EAttWidowOrphan))
|
sl@0
|
307 |
iWidowOrphan=aFormat.iWidowOrphan;
|
sl@0
|
308 |
if (aMask.AttribIsSet(EAttWrap))
|
sl@0
|
309 |
iWrap=aFormat.iWrap;
|
sl@0
|
310 |
|
sl@0
|
311 |
// Copy borders; create a border array only if necessary.
|
sl@0
|
312 |
if (iParaBorderArray || aFormat.iParaBorderArray)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
if (!iParaBorderArray)
|
sl@0
|
315 |
iParaBorderArray = new(ELeave) TParaBorderArray;
|
sl@0
|
316 |
if (aMask.AttribIsSet(EAttTopBorder))
|
sl@0
|
317 |
iParaBorderArray->iBorder[EParaBorderTop] = aFormat.ParaBorder(EParaBorderTop);
|
sl@0
|
318 |
if (aMask.AttribIsSet(EAttBottomBorder))
|
sl@0
|
319 |
iParaBorderArray->iBorder[EParaBorderBottom] = aFormat.ParaBorder(EParaBorderBottom);
|
sl@0
|
320 |
if (aMask.AttribIsSet(EAttLeftBorder))
|
sl@0
|
321 |
iParaBorderArray->iBorder[EParaBorderLeft] = aFormat.ParaBorder(EParaBorderLeft);
|
sl@0
|
322 |
if (aMask.AttribIsSet(EAttRightBorder))
|
sl@0
|
323 |
iParaBorderArray->iBorder[EParaBorderRight] = aFormat.ParaBorder(EParaBorderRight);
|
sl@0
|
324 |
TParaBorder default_border;
|
sl@0
|
325 |
TBool borders_are_default = TRUE;
|
sl@0
|
326 |
for (int i = 0; i < 4; i++)
|
sl@0
|
327 |
if (iParaBorderArray->iBorder[i] != default_border)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
borders_are_default = FALSE;
|
sl@0
|
330 |
break;
|
sl@0
|
331 |
}
|
sl@0
|
332 |
if (borders_are_default)
|
sl@0
|
333 |
RemoveAllBorders();
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
if (iBullet || aFormat.iBullet)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
if (aMask.AttribIsSet(EAttBullet))
|
sl@0
|
339 |
{
|
sl@0
|
340 |
if (aFormat.iBullet && aFormat.iBullet->iStyle != TBullet::ENullStyle)
|
sl@0
|
341 |
{
|
sl@0
|
342 |
if (!iBullet)
|
sl@0
|
343 |
iBullet = new(ELeave) TBullet;
|
sl@0
|
344 |
*iBullet = *aFormat.iBullet;
|
sl@0
|
345 |
}
|
sl@0
|
346 |
else
|
sl@0
|
347 |
{
|
sl@0
|
348 |
delete iBullet;
|
sl@0
|
349 |
iBullet = NULL;
|
sl@0
|
350 |
}
|
sl@0
|
351 |
}
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
if (aMask.AttribIsSet(EAttDefaultTabWidth))
|
sl@0
|
355 |
iDefaultTabWidthInTwips = aFormat.iDefaultTabWidthInTwips;
|
sl@0
|
356 |
|
sl@0
|
357 |
if (iTabList || aFormat.iTabList)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
if (aMask.AttribIsSet(EAttTabStop))
|
sl@0
|
360 |
{
|
sl@0
|
361 |
RemoveAllTabs();
|
sl@0
|
362 |
if (aFormat.iTabList && aFormat.iTabList->Count())
|
sl@0
|
363 |
{
|
sl@0
|
364 |
CreateTabListL();
|
sl@0
|
365 |
iTabList->InsertL(0,&(aFormat.iTabList->At(0)),aFormat.iTabList->Count());
|
sl@0
|
366 |
}
|
sl@0
|
367 |
}
|
sl@0
|
368 |
}
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
EXPORT_C TBool CParaFormat::IsEqual(const CParaFormat& aFormat,const TParaFormatMask& aMask) const
|
sl@0
|
372 |
/** Compares selected attribute values for equality. Only the attributes
|
sl@0
|
373 |
specified in the mask are involved in the comparison.
|
sl@0
|
374 |
|
sl@0
|
375 |
@param aFormat Contains the attribute values to compare.
|
sl@0
|
376 |
@param aMask Bitmask specifying the attributes to compare.
|
sl@0
|
377 |
@return ETrue if the two format containers have the same values for the
|
sl@0
|
378 |
attributes specified in the mask, EFalse if not. */
|
sl@0
|
379 |
{
|
sl@0
|
380 |
if (aMask.AttribIsSet(EAttParaLanguage))
|
sl@0
|
381 |
{
|
sl@0
|
382 |
if (iLanguage!=aFormat.iLanguage)
|
sl@0
|
383 |
return EFalse;
|
sl@0
|
384 |
}
|
sl@0
|
385 |
if (aMask.AttribIsSet(EAttFillColor))
|
sl@0
|
386 |
{
|
sl@0
|
387 |
if (iFillColor!=aFormat.iFillColor)
|
sl@0
|
388 |
return EFalse;
|
sl@0
|
389 |
}
|
sl@0
|
390 |
if (aMask.AttribIsSet(EAttLeftMargin))
|
sl@0
|
391 |
{
|
sl@0
|
392 |
if (iLeftMarginInTwips!=aFormat.iLeftMarginInTwips)
|
sl@0
|
393 |
return EFalse;
|
sl@0
|
394 |
}
|
sl@0
|
395 |
if (aMask.AttribIsSet(EAttRightMargin))
|
sl@0
|
396 |
{
|
sl@0
|
397 |
if (iRightMarginInTwips!=aFormat.iRightMarginInTwips)
|
sl@0
|
398 |
return EFalse;
|
sl@0
|
399 |
}
|
sl@0
|
400 |
if (aMask.AttribIsSet(EAttIndent))
|
sl@0
|
401 |
{
|
sl@0
|
402 |
if (iIndentInTwips!=aFormat.iIndentInTwips)
|
sl@0
|
403 |
return EFalse;
|
sl@0
|
404 |
}
|
sl@0
|
405 |
if (aMask.AttribIsSet(EAttAlignment))
|
sl@0
|
406 |
{
|
sl@0
|
407 |
if (iHorizontalAlignment!=aFormat.iHorizontalAlignment)
|
sl@0
|
408 |
return EFalse;
|
sl@0
|
409 |
}
|
sl@0
|
410 |
if (aMask.AttribIsSet(EAttVerticalAlignment))
|
sl@0
|
411 |
{
|
sl@0
|
412 |
if (iVerticalAlignment!=aFormat.iVerticalAlignment)
|
sl@0
|
413 |
return EFalse;
|
sl@0
|
414 |
}
|
sl@0
|
415 |
if (aMask.AttribIsSet(EAttLineSpacing))
|
sl@0
|
416 |
{
|
sl@0
|
417 |
if (iLineSpacingInTwips!=aFormat.iLineSpacingInTwips)
|
sl@0
|
418 |
return EFalse;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
if (aMask.AttribIsSet(EAttLineSpacingControl))
|
sl@0
|
421 |
{
|
sl@0
|
422 |
if (iLineSpacingControl!=aFormat.iLineSpacingControl)
|
sl@0
|
423 |
return EFalse;
|
sl@0
|
424 |
}
|
sl@0
|
425 |
if (aMask.AttribIsSet(EAttSpaceBefore))
|
sl@0
|
426 |
{
|
sl@0
|
427 |
if (iSpaceBeforeInTwips!=aFormat.iSpaceBeforeInTwips)
|
sl@0
|
428 |
return EFalse;
|
sl@0
|
429 |
}
|
sl@0
|
430 |
if (aMask.AttribIsSet(EAttSpaceAfter))
|
sl@0
|
431 |
{
|
sl@0
|
432 |
if (iSpaceAfterInTwips!=aFormat.iSpaceAfterInTwips)
|
sl@0
|
433 |
return EFalse;
|
sl@0
|
434 |
}
|
sl@0
|
435 |
if (aMask.AttribIsSet(EAttKeepTogether))
|
sl@0
|
436 |
{
|
sl@0
|
437 |
if (iKeepTogether!=aFormat.iKeepTogether)
|
sl@0
|
438 |
return EFalse;
|
sl@0
|
439 |
}
|
sl@0
|
440 |
if (aMask.AttribIsSet(EAttKeepWithNext))
|
sl@0
|
441 |
{
|
sl@0
|
442 |
if (iKeepWithNext!=aFormat.iKeepWithNext)
|
sl@0
|
443 |
return EFalse;
|
sl@0
|
444 |
}
|
sl@0
|
445 |
if (aMask.AttribIsSet(EAttStartNewPage))
|
sl@0
|
446 |
{
|
sl@0
|
447 |
if (iStartNewPage!=aFormat.iStartNewPage)
|
sl@0
|
448 |
return EFalse;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
if (aMask.AttribIsSet(EAttWidowOrphan))
|
sl@0
|
451 |
{
|
sl@0
|
452 |
if (iWidowOrphan!=aFormat.iWidowOrphan)
|
sl@0
|
453 |
return EFalse;
|
sl@0
|
454 |
}
|
sl@0
|
455 |
if (aMask.AttribIsSet(EAttWrap))
|
sl@0
|
456 |
{
|
sl@0
|
457 |
if (iWrap!=aFormat.iWrap)
|
sl@0
|
458 |
return EFalse;
|
sl@0
|
459 |
}
|
sl@0
|
460 |
if (aMask.AttribIsSet(EAttBorderMargin))
|
sl@0
|
461 |
{
|
sl@0
|
462 |
if (iBorderMarginInTwips!=aFormat.iBorderMarginInTwips)
|
sl@0
|
463 |
return EFalse;
|
sl@0
|
464 |
}
|
sl@0
|
465 |
if (aMask.AttribIsSet(EAttTopBorder))
|
sl@0
|
466 |
{
|
sl@0
|
467 |
if (iParaBorderArray)
|
sl@0
|
468 |
{
|
sl@0
|
469 |
if (ParaBorder(EParaBorderTop)!=aFormat.ParaBorder(EParaBorderTop))
|
sl@0
|
470 |
return EFalse;
|
sl@0
|
471 |
}
|
sl@0
|
472 |
else
|
sl@0
|
473 |
{
|
sl@0
|
474 |
if (aFormat.ParaBorder(EParaBorderTop).iLineStyle!=TParaBorder::ENullLineStyle)
|
sl@0
|
475 |
return EFalse;
|
sl@0
|
476 |
}
|
sl@0
|
477 |
}
|
sl@0
|
478 |
if (aMask.AttribIsSet(EAttBottomBorder))
|
sl@0
|
479 |
{
|
sl@0
|
480 |
if (iParaBorderArray)
|
sl@0
|
481 |
{
|
sl@0
|
482 |
if (ParaBorder(EParaBorderBottom)!=aFormat.ParaBorder(EParaBorderBottom))
|
sl@0
|
483 |
return EFalse;
|
sl@0
|
484 |
}
|
sl@0
|
485 |
else
|
sl@0
|
486 |
{
|
sl@0
|
487 |
if (aFormat.ParaBorder(EParaBorderBottom).iLineStyle!=TParaBorder::ENullLineStyle)
|
sl@0
|
488 |
return EFalse;
|
sl@0
|
489 |
}
|
sl@0
|
490 |
}
|
sl@0
|
491 |
if (aMask.AttribIsSet(EAttLeftBorder))
|
sl@0
|
492 |
{
|
sl@0
|
493 |
if (iParaBorderArray)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
if (ParaBorder(EParaBorderLeft)!=aFormat.ParaBorder(EParaBorderLeft))
|
sl@0
|
496 |
return EFalse;
|
sl@0
|
497 |
}
|
sl@0
|
498 |
else
|
sl@0
|
499 |
{
|
sl@0
|
500 |
if (aFormat.ParaBorder(EParaBorderLeft).iLineStyle!=TParaBorder::ENullLineStyle)
|
sl@0
|
501 |
return EFalse;
|
sl@0
|
502 |
}
|
sl@0
|
503 |
}
|
sl@0
|
504 |
if (aMask.AttribIsSet(EAttRightBorder))
|
sl@0
|
505 |
{
|
sl@0
|
506 |
if (iParaBorderArray)
|
sl@0
|
507 |
{
|
sl@0
|
508 |
if (ParaBorder(EParaBorderRight)!=aFormat.ParaBorder(EParaBorderRight))
|
sl@0
|
509 |
return EFalse;
|
sl@0
|
510 |
}
|
sl@0
|
511 |
else
|
sl@0
|
512 |
{
|
sl@0
|
513 |
if (aFormat.ParaBorder(EParaBorderRight).iLineStyle!=TParaBorder::ENullLineStyle)
|
sl@0
|
514 |
return EFalse;
|
sl@0
|
515 |
}
|
sl@0
|
516 |
}
|
sl@0
|
517 |
if (aMask.AttribIsSet(EAttBullet))
|
sl@0
|
518 |
{
|
sl@0
|
519 |
if (iBullet)
|
sl@0
|
520 |
{
|
sl@0
|
521 |
if (!aFormat.iBullet)
|
sl@0
|
522 |
return EFalse;
|
sl@0
|
523 |
if (*iBullet!=*aFormat.iBullet)
|
sl@0
|
524 |
return EFalse;
|
sl@0
|
525 |
}
|
sl@0
|
526 |
else
|
sl@0
|
527 |
{
|
sl@0
|
528 |
if (aFormat.iBullet)
|
sl@0
|
529 |
return EFalse;
|
sl@0
|
530 |
}
|
sl@0
|
531 |
}
|
sl@0
|
532 |
if (aMask.AttribIsSet(EAttDefaultTabWidth))
|
sl@0
|
533 |
{
|
sl@0
|
534 |
if (iDefaultTabWidthInTwips!=aFormat.iDefaultTabWidthInTwips)
|
sl@0
|
535 |
return EFalse;
|
sl@0
|
536 |
}
|
sl@0
|
537 |
if (aMask.AttribIsSet(EAttTabStop))
|
sl@0
|
538 |
{
|
sl@0
|
539 |
if (TabCount()>0)
|
sl@0
|
540 |
{// Check the tablists are the same.
|
sl@0
|
541 |
if (TabCount()!=aFormat.TabCount())
|
sl@0
|
542 |
return EFalse;
|
sl@0
|
543 |
TInt tabCount=TabCount();
|
sl@0
|
544 |
for (TInt index=0;index<tabCount;index++)
|
sl@0
|
545 |
{// Check each stored tab is the same
|
sl@0
|
546 |
if (TabStop(index)!=aFormat.TabStop(index))
|
sl@0
|
547 |
return EFalse;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
}
|
sl@0
|
550 |
else if (aFormat.TabCount()>0)
|
sl@0
|
551 |
return EFalse;
|
sl@0
|
552 |
}
|
sl@0
|
553 |
return ETrue;
|
sl@0
|
554 |
}
|
sl@0
|
555 |
|
sl@0
|
556 |
EXPORT_C TBool CParaFormat::IsEqual(const CParaFormat& aFormat) const
|
sl@0
|
557 |
/** Compares all attribute values for equality.
|
sl@0
|
558 |
|
sl@0
|
559 |
@param aFormat Contains the attribute values to compare.
|
sl@0
|
560 |
@return ETrue if the two format containers have the same values for all
|
sl@0
|
561 |
attributes, EFalse if not. */
|
sl@0
|
562 |
{
|
sl@0
|
563 |
TParaFormatMask mask;
|
sl@0
|
564 |
mask.SetAll();
|
sl@0
|
565 |
return IsEqual(aFormat,mask);
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
EXPORT_C void CParaFormat::Strip()
|
sl@0
|
569 |
/** Deletes all paragraph borders, bullets and tab stops. No other
|
sl@0
|
570 |
attributes are affected. */
|
sl@0
|
571 |
{
|
sl@0
|
572 |
RemoveAllTabs();
|
sl@0
|
573 |
RemoveAllBorders();
|
sl@0
|
574 |
delete iBullet;
|
sl@0
|
575 |
iBullet = NULL;
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
EXPORT_C void CParaFormat::Reset()
|
sl@0
|
579 |
/** Resets all paragraph format attributes to their default values. All tab
|
sl@0
|
580 |
stops, paragraph borders and bullet points which have been allocated are
|
sl@0
|
581 |
deleted and set to NULL. */
|
sl@0
|
582 |
{
|
sl@0
|
583 |
ResetNonDestructive();
|
sl@0
|
584 |
Strip();
|
sl@0
|
585 |
}
|
sl@0
|
586 |
|
sl@0
|
587 |
EXPORT_C void CParaFormat::ResetNonDestructive()
|
sl@0
|
588 |
/** Resets all paragraph format attributes to their default values, but any
|
sl@0
|
589 |
allocated tab stops, bullet points and paragraph borders are preserved. */
|
sl@0
|
590 |
{
|
sl@0
|
591 |
iLanguage=KParaDefaultLanguage;
|
sl@0
|
592 |
iFillColor=TLogicalRgb::ESystemBackgroundColor;
|
sl@0
|
593 |
iLeftMarginInTwips=KParaDefaultLeftMargin;
|
sl@0
|
594 |
iRightMarginInTwips=KParaDefaultRightMargin;
|
sl@0
|
595 |
iIndentInTwips=KParaDefaultIndent;
|
sl@0
|
596 |
iHorizontalAlignment=KParaDefaultHorizAlign;
|
sl@0
|
597 |
iVerticalAlignment=KParaDefaultVertAlign;
|
sl@0
|
598 |
iLineSpacingInTwips=KParaDefaultLineSpacing;
|
sl@0
|
599 |
iLineSpacingControl=KParaDefaultLineSpacingControl;
|
sl@0
|
600 |
iSpaceBeforeInTwips=KParaDefaultSpaceBefore;
|
sl@0
|
601 |
iSpaceAfterInTwips=KParaDefaultSpaceAfter;
|
sl@0
|
602 |
iKeepTogether=KParaDefaultKeepTogether;
|
sl@0
|
603 |
iKeepWithNext=KParaDefaultKeepWithNext;
|
sl@0
|
604 |
iStartNewPage=KParaDefaultStartNewPage;
|
sl@0
|
605 |
iWidowOrphan=KParaDefaultWidowOrphan;
|
sl@0
|
606 |
iWrap=KParaDefaultWrap;
|
sl@0
|
607 |
iBorderMarginInTwips=KParaDefaultBorderMargin;
|
sl@0
|
608 |
iDefaultTabWidthInTwips=KParaDefaultTabWidth;
|
sl@0
|
609 |
}
|
sl@0
|
610 |
|
sl@0
|
611 |
EXPORT_C void CParaFormat::StoreTabL(const TTabStop& aTabStop)
|
sl@0
|
612 |
/** Adds a tab stop to the list of tab stops, maintaining the ordering of the
|
sl@0
|
613 |
list, (ascending order of twips position). Multiple tabs with the same twips
|
sl@0
|
614 |
position are not allowed, so that if aTabStop shares the same twips position
|
sl@0
|
615 |
as an existing tab stop, regardless of its alignment, the existing tab stop is
|
sl@0
|
616 |
replaced by aTabStop.
|
sl@0
|
617 |
|
sl@0
|
618 |
@param aTabStop The tab stop to be stored. */
|
sl@0
|
619 |
{
|
sl@0
|
620 |
CreateTabListL();
|
sl@0
|
621 |
TKeyArrayFix tabKey(_FOFF(TTabStop,iTwipsPosition),ECmpTUint32);
|
sl@0
|
622 |
TInt tabNumber;
|
sl@0
|
623 |
CArrayFixFlat<TTabStop>& tabs=*iTabList;
|
sl@0
|
624 |
if (tabs.FindIsq(aTabStop,tabKey,tabNumber)==0)
|
sl@0
|
625 |
tabs[tabNumber]=aTabStop; // found one at this position
|
sl@0
|
626 |
else
|
sl@0
|
627 |
tabs.InsertL(tabNumber,aTabStop); // add the new one
|
sl@0
|
628 |
}
|
sl@0
|
629 |
|
sl@0
|
630 |
EXPORT_C void CParaFormat::RemoveTab(TInt aTabPosition)
|
sl@0
|
631 |
/** Deletes a tab stop identified by its twips position. If the specified
|
sl@0
|
632 |
tab stop does not exist, the function has no effect.
|
sl@0
|
633 |
|
sl@0
|
634 |
@param aTabTwipsPosition The twips position of the tab stop to remove. */
|
sl@0
|
635 |
|
sl@0
|
636 |
{
|
sl@0
|
637 |
TInt tabNumber=LocateTab(aTabPosition); // will return KTabNotFound if no tab list present
|
sl@0
|
638 |
if (tabNumber!=KTabNotFound)
|
sl@0
|
639 |
{
|
sl@0
|
640 |
iTabList->Delete(tabNumber);
|
sl@0
|
641 |
iTabList->Compress();
|
sl@0
|
642 |
}
|
sl@0
|
643 |
}
|
sl@0
|
644 |
|
sl@0
|
645 |
EXPORT_C const TTabStop CParaFormat::TabStop(TInt aTabIndex) const
|
sl@0
|
646 |
/** Gets the tab stop located at the specified index within the tab list
|
sl@0
|
647 |
(counting from zero). Tab stops are ordered in ascending order of twips
|
sl@0
|
648 |
position. If the object has no tab list, then a default tab stop is returned.
|
sl@0
|
649 |
|
sl@0
|
650 |
@param aTabIndex The offset of the tab stop in the tab list. Must be less
|
sl@0
|
651 |
than the total number of tab stops, or a panic occurs. To find the total number
|
sl@0
|
652 |
of tab stops, use TabCount().
|
sl@0
|
653 |
@return The tab stop located at the specified index. */
|
sl@0
|
654 |
{
|
sl@0
|
655 |
if (aTabIndex>=TabCount())
|
sl@0
|
656 |
{
|
sl@0
|
657 |
OstTrace0( TRACE_FATAL, CPARAFORMAT_TABSTOP, "ETabNotFound" );
|
sl@0
|
658 |
}
|
sl@0
|
659 |
__ASSERT_ALWAYS(aTabIndex<TabCount(),Panic(ETabNotFound));
|
sl@0
|
660 |
|
sl@0
|
661 |
return (iTabList)
|
sl@0
|
662 |
? TTabStop((*iTabList)[aTabIndex])
|
sl@0
|
663 |
: TTabStop();
|
sl@0
|
664 |
}
|
sl@0
|
665 |
|
sl@0
|
666 |
EXPORT_C TInt CParaFormat::LocateTab(TInt aTabPosition) const
|
sl@0
|
667 |
/** Locates the tab stop specified by its twips position, and returns its
|
sl@0
|
668 |
offset in the tab list.
|
sl@0
|
669 |
|
sl@0
|
670 |
@param aTabPosition The twips position of the tab stop.
|
sl@0
|
671 |
@return The tab stop's index within the tab list (counting from zero).
|
sl@0
|
672 |
KTabNotFound indicates that no tab stop has the specified twips
|
sl@0
|
673 |
position, or that no tab list has been allocated. */
|
sl@0
|
674 |
{
|
sl@0
|
675 |
if (!iTabList)
|
sl@0
|
676 |
return KTabNotFound;
|
sl@0
|
677 |
TKeyArrayFix tabKey(_FOFF(TTabStop,iTwipsPosition),ECmpTUint32);
|
sl@0
|
678 |
TInt tabNumber=0;
|
sl@0
|
679 |
TTabStop tab;
|
sl@0
|
680 |
tab.iTwipsPosition=aTabPosition;
|
sl@0
|
681 |
TInt error=iTabList->FindIsq(tab,tabKey,tabNumber);
|
sl@0
|
682 |
return error ?KTabNotFound :tabNumber;
|
sl@0
|
683 |
}
|
sl@0
|
684 |
|
sl@0
|
685 |
EXPORT_C void CParaFormat::SetParaBorderL(TParaBorderSide aSide,const TParaBorder& aBorder)
|
sl@0
|
686 |
/** Sets one side of the object's paragraph border. If a border on the specified
|
sl@0
|
687 |
side already exists, it is replaced.
|
sl@0
|
688 |
|
sl@0
|
689 |
Note: Setting a single side of the object's paragraph border incurs the overhead
|
sl@0
|
690 |
of allocating storage for the three other sides, which are assigned default
|
sl@0
|
691 |
values.
|
sl@0
|
692 |
|
sl@0
|
693 |
@param aSide The side for the paragraph border.
|
sl@0
|
694 |
@param aBorder Specification for the paragraph border. */
|
sl@0
|
695 |
{
|
sl@0
|
696 |
TParaBorderArray* borders=iParaBorderArray;
|
sl@0
|
697 |
if (!borders)
|
sl@0
|
698 |
iParaBorderArray=borders=new(ELeave) TParaBorderArray;
|
sl@0
|
699 |
borders->iBorder[aSide]=aBorder;
|
sl@0
|
700 |
}
|
sl@0
|
701 |
|
sl@0
|
702 |
EXPORT_C const TParaBorder CParaFormat::ParaBorder(TParaBorderSide aSide)const
|
sl@0
|
703 |
/** Gets the paragraph border on the side specified. If no paragraph border
|
sl@0
|
704 |
array has been allocated, returns a default paragraph border.
|
sl@0
|
705 |
|
sl@0
|
706 |
@param aSide The side for the paragraph border.
|
sl@0
|
707 |
@return The paragraph border on the specified side. */
|
sl@0
|
708 |
{
|
sl@0
|
709 |
if (iParaBorderArray)
|
sl@0
|
710 |
return iParaBorderArray->iBorder[aSide];
|
sl@0
|
711 |
return TParaBorder();
|
sl@0
|
712 |
}
|
sl@0
|
713 |
|
sl@0
|
714 |
EXPORT_C void CParaFormat::RemoveAllBorders()
|
sl@0
|
715 |
/** Deletes all paragraph borders. */
|
sl@0
|
716 |
{
|
sl@0
|
717 |
delete iParaBorderArray;
|
sl@0
|
718 |
iParaBorderArray = NULL;
|
sl@0
|
719 |
}
|
sl@0
|
720 |
|
sl@0
|
721 |
EXPORT_C TBool CParaFormat::AllBordersEqual(const CParaFormat& aFormat)const
|
sl@0
|
722 |
/** Tests whether all paragraph borders in the specified paragraph format
|
sl@0
|
723 |
container are identical to the paragraph borders of this paragraph format
|
sl@0
|
724 |
container.
|
sl@0
|
725 |
|
sl@0
|
726 |
@param aFormat Contains the set of paragraph borders to compare.
|
sl@0
|
727 |
@return ETrue if both objects have exactly the same set of paragraph borders.
|
sl@0
|
728 |
EFalse if not. */
|
sl@0
|
729 |
{
|
sl@0
|
730 |
if (aFormat.ParaBorder(EParaBorderTop)!=ParaBorder(EParaBorderTop))
|
sl@0
|
731 |
return EFalse;
|
sl@0
|
732 |
if (aFormat.ParaBorder(EParaBorderBottom)!=ParaBorder(EParaBorderBottom))
|
sl@0
|
733 |
return EFalse;
|
sl@0
|
734 |
if (aFormat.ParaBorder(EParaBorderLeft)!=ParaBorder(EParaBorderLeft))
|
sl@0
|
735 |
return EFalse;
|
sl@0
|
736 |
if (aFormat.ParaBorder(EParaBorderRight)!=ParaBorder(EParaBorderRight))
|
sl@0
|
737 |
return EFalse;
|
sl@0
|
738 |
return ETrue;
|
sl@0
|
739 |
}
|
sl@0
|
740 |
|
sl@0
|
741 |
EXPORT_C TBool CParaFormat::IsBorderEqual(TParaBorderSide aSide,const CParaFormat& aFormat)const
|
sl@0
|
742 |
/** Tests whether the paragraph border located on the specified side is the same
|
sl@0
|
743 |
as the border on the corresponding side in this object. For two borders to
|
sl@0
|
744 |
be equal, they must both either be set or unset, and if set, they must have
|
sl@0
|
745 |
the same characteristics.
|
sl@0
|
746 |
|
sl@0
|
747 |
@param aSide Indicates which side should be compared.
|
sl@0
|
748 |
@param aFormat Contains the paragraph border to compare.
|
sl@0
|
749 |
@return ETrue if the border sides are identical. EFalse if not. */
|
sl@0
|
750 |
{
|
sl@0
|
751 |
return aFormat.ParaBorder(aSide)==ParaBorder(aSide);
|
sl@0
|
752 |
}
|
sl@0
|
753 |
|
sl@0
|
754 |
EXPORT_C void TParaFormatMask::SetAll()
|
sl@0
|
755 |
/** Sets all attribute flags in the paragraph format mask. */
|
sl@0
|
756 |
{
|
sl@0
|
757 |
iGuard = KMaxTUint;
|
sl@0
|
758 |
}
|
sl@0
|
759 |
|
sl@0
|
760 |
EXPORT_C void TParaFormatMask::ClearAll()
|
sl@0
|
761 |
/** Clears all attribute flags in the paragraph format mask. */
|
sl@0
|
762 |
{
|
sl@0
|
763 |
iGuard=0;
|
sl@0
|
764 |
}
|
sl@0
|
765 |
|
sl@0
|
766 |
EXPORT_C TBool TParaFormatMask::operator==(const TParaFormatMask& aMask)const
|
sl@0
|
767 |
/** Compares two paragraph format masks for equality.
|
sl@0
|
768 |
|
sl@0
|
769 |
@param aMask The mask to compare.
|
sl@0
|
770 |
@return ETrue if all flags are the same in both masks. EFalse if any differ. */
|
sl@0
|
771 |
{
|
sl@0
|
772 |
return (iGuard & KParFormatBits) == (aMask.iGuard & KParFormatBits);
|
sl@0
|
773 |
}
|
sl@0
|
774 |
|
sl@0
|
775 |
EXPORT_C TFontPresentation::TFontPresentation():
|
sl@0
|
776 |
iTextColor(TLogicalRgb::ESystemForegroundColor),
|
sl@0
|
777 |
iHighlightColor(TLogicalRgb::ESystemForegroundColor),
|
sl@0
|
778 |
iHighlightStyle(EFontHighlightNone),
|
sl@0
|
779 |
iStrikethrough(EStrikethroughOff),
|
sl@0
|
780 |
iUnderline(EUnderlineOff),
|
sl@0
|
781 |
iHiddenText(EFalse),
|
sl@0
|
782 |
iPictureAlignment(EAlignBaseLine)
|
sl@0
|
783 |
/** The default C++ constructor constructs a TFontPresentation object,
|
sl@0
|
784 |
initializing all member data to default values. For details of these values,
|
sl@0
|
785 |
see the table below. */
|
sl@0
|
786 |
{
|
sl@0
|
787 |
}
|
sl@0
|
788 |
|
sl@0
|
789 |
EXPORT_C TBool TFontPresentation::IsEqual(const TFontPresentation& aFontPresentation,const TCharFormatMask& aMask) const
|
sl@0
|
790 |
/** Compares selected attribute values for equality. Only the attributes
|
sl@0
|
791 |
specified in the mask are involved in the comparison.
|
sl@0
|
792 |
|
sl@0
|
793 |
@param aFontPresentation Contains the attribute values to compare.
|
sl@0
|
794 |
@param aMask Bitmask specifying the attributes involved in the comparison.
|
sl@0
|
795 |
@return ETrue if the two objects have the same values for the attributes
|
sl@0
|
796 |
specified in the mask, EFalse if not. */
|
sl@0
|
797 |
{
|
sl@0
|
798 |
// Compare two font presentations, comparing only the attributes selected by the mask.
|
sl@0
|
799 |
if (aMask.AttribIsSet(EAttColor))
|
sl@0
|
800 |
{
|
sl@0
|
801 |
if (iTextColor!=aFontPresentation.iTextColor)
|
sl@0
|
802 |
return EFalse;
|
sl@0
|
803 |
}
|
sl@0
|
804 |
if (aMask.AttribIsSet(EAttFontHighlightColor))
|
sl@0
|
805 |
{
|
sl@0
|
806 |
if (iHighlightColor!=aFontPresentation.iHighlightColor)
|
sl@0
|
807 |
return EFalse;
|
sl@0
|
808 |
}
|
sl@0
|
809 |
if (aMask.AttribIsSet(EAttFontHighlightStyle))
|
sl@0
|
810 |
{
|
sl@0
|
811 |
if (iHighlightStyle!=aFontPresentation.iHighlightStyle)
|
sl@0
|
812 |
return EFalse;
|
sl@0
|
813 |
}
|
sl@0
|
814 |
if (aMask.AttribIsSet(EAttFontStrikethrough))
|
sl@0
|
815 |
{
|
sl@0
|
816 |
if (iStrikethrough!=aFontPresentation.iStrikethrough)
|
sl@0
|
817 |
return EFalse;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
if (aMask.AttribIsSet(EAttFontUnderline))
|
sl@0
|
820 |
{
|
sl@0
|
821 |
if (iUnderline!=aFontPresentation.iUnderline)
|
sl@0
|
822 |
return EFalse;
|
sl@0
|
823 |
}
|
sl@0
|
824 |
if (aMask.AttribIsSet(EAttFontHiddenText))
|
sl@0
|
825 |
{
|
sl@0
|
826 |
if (iHiddenText!=aFontPresentation.iHiddenText)
|
sl@0
|
827 |
return EFalse;
|
sl@0
|
828 |
}
|
sl@0
|
829 |
if (aMask.AttribIsSet(EAttFontPictureAlignment))
|
sl@0
|
830 |
{
|
sl@0
|
831 |
if (iPictureAlignment!=aFontPresentation.iPictureAlignment)
|
sl@0
|
832 |
return EFalse;
|
sl@0
|
833 |
}
|
sl@0
|
834 |
return ETrue;
|
sl@0
|
835 |
}
|
sl@0
|
836 |
|
sl@0
|
837 |
EXPORT_C TCharFormat::TCharFormat():
|
sl@0
|
838 |
iLanguage(0)
|
sl@0
|
839 |
/** Allocates and constructs a TCharFormat object. The font-independent
|
sl@0
|
840 |
attributes are initialised with default values. The language is initialised
|
sl@0
|
841 |
to zero. The font (iFontSpec) is set to be proportional and serif and to have
|
sl@0
|
842 |
a height of 200 twips. The typeface name is not initialised. */
|
sl@0
|
843 |
{
|
sl@0
|
844 |
iFontSpec.iTypeface.SetAttributes(TTypeface::EProportional | TTypeface::ESerif);
|
sl@0
|
845 |
iFontSpec.iHeight = 200;
|
sl@0
|
846 |
}
|
sl@0
|
847 |
|
sl@0
|
848 |
EXPORT_C TCharFormat::TCharFormat(const TDesC &aTypefaceName,TInt aHeight):
|
sl@0
|
849 |
iLanguage(0),
|
sl@0
|
850 |
iFontSpec(aTypefaceName,aHeight)
|
sl@0
|
851 |
/** The C++ constructor is used to construct the TCharFormat object with a font
|
sl@0
|
852 |
(typeface name and font height). The font-independent attributes are initialised
|
sl@0
|
853 |
to default values; for details, see class TFontPresentation. The language
|
sl@0
|
854 |
is initialised to zero.
|
sl@0
|
855 |
|
sl@0
|
856 |
@param aTypefaceName Specifies the typeface name.
|
sl@0
|
857 |
@param aHeight Specifies the font height in twips. */
|
sl@0
|
858 |
{
|
sl@0
|
859 |
}
|
sl@0
|
860 |
|
sl@0
|
861 |
EXPORT_C TBool TCharFormat::IsEqual(const TCharFormat& aFormat,const TCharFormatMask& aMask) const
|
sl@0
|
862 |
/** Compares selected attribute values for equality. Only the attributes
|
sl@0
|
863 |
specified in the mask are involved in the comparison.
|
sl@0
|
864 |
|
sl@0
|
865 |
@param aFormat Contains the attribute values to compare.
|
sl@0
|
866 |
@param aMask Bitmask specifying the attributes to compare.
|
sl@0
|
867 |
@return ETrue if the two format containers have the same values for the
|
sl@0
|
868 |
attributes specified in the mask, EFalse if not. */
|
sl@0
|
869 |
{
|
sl@0
|
870 |
if (aMask.AttribIsSet(EAttCharLanguage))
|
sl@0
|
871 |
{
|
sl@0
|
872 |
if (iLanguage!=aFormat.iLanguage)
|
sl@0
|
873 |
return EFalse;
|
sl@0
|
874 |
}
|
sl@0
|
875 |
if (!iFontPresentation.IsEqual(aFormat.iFontPresentation,aMask))
|
sl@0
|
876 |
return EFalse;
|
sl@0
|
877 |
if (aMask.AttribIsSet(EAttFontHeight))
|
sl@0
|
878 |
{
|
sl@0
|
879 |
if (iFontSpec.iHeight!=aFormat.iFontSpec.iHeight)
|
sl@0
|
880 |
return EFalse;
|
sl@0
|
881 |
}
|
sl@0
|
882 |
if (aMask.AttribIsSet(EAttFontTypeface))
|
sl@0
|
883 |
{
|
sl@0
|
884 |
if (!(iFontSpec.iTypeface==aFormat.iFontSpec.iTypeface))
|
sl@0
|
885 |
return EFalse;
|
sl@0
|
886 |
}
|
sl@0
|
887 |
if (aMask.AttribIsSet(EAttFontPosture))
|
sl@0
|
888 |
{
|
sl@0
|
889 |
if (iFontSpec.iFontStyle.Posture()!=aFormat.iFontSpec.iFontStyle.Posture())
|
sl@0
|
890 |
return EFalse;
|
sl@0
|
891 |
}
|
sl@0
|
892 |
if (aMask.AttribIsSet(EAttFontStrokeWeight))
|
sl@0
|
893 |
{
|
sl@0
|
894 |
if (iFontSpec.iFontStyle.StrokeWeight()!=aFormat.iFontSpec.iFontStyle.StrokeWeight())
|
sl@0
|
895 |
return EFalse;
|
sl@0
|
896 |
}
|
sl@0
|
897 |
if (aMask.AttribIsSet(EAttFontPrintPos))
|
sl@0
|
898 |
{
|
sl@0
|
899 |
if (iFontSpec.iFontStyle.PrintPosition()!=aFormat.iFontSpec.iFontStyle.PrintPosition())
|
sl@0
|
900 |
return EFalse;
|
sl@0
|
901 |
}
|
sl@0
|
902 |
return ETrue;
|
sl@0
|
903 |
}
|
sl@0
|
904 |
|
sl@0
|
905 |
|
sl@0
|
906 |
EXPORT_C TBool TCharFormat::IsEqual(const TCharFormat& aFormat) const
|
sl@0
|
907 |
/** Compares all attribute values for equality.
|
sl@0
|
908 |
|
sl@0
|
909 |
@param aFormat Contains the attribute values to compare.
|
sl@0
|
910 |
@return ETrue if the two format containers have the same values for all
|
sl@0
|
911 |
attributes, EFalse if not. */
|
sl@0
|
912 |
{
|
sl@0
|
913 |
TCharFormatMask mask;
|
sl@0
|
914 |
mask.SetAll();
|
sl@0
|
915 |
return IsEqual(aFormat,mask);
|
sl@0
|
916 |
}
|
sl@0
|
917 |
|
sl@0
|
918 |
EXPORT_C void TCharFormatMask::SetAll()
|
sl@0
|
919 |
/** Sets all attribute flags in the character format mask. */
|
sl@0
|
920 |
{
|
sl@0
|
921 |
iGuard = KMaxTUint;
|
sl@0
|
922 |
}
|
sl@0
|
923 |
|
sl@0
|
924 |
EXPORT_C void TCharFormatMask::ClearAll()
|
sl@0
|
925 |
/** Clears all attribute flags in the character format mask. */
|
sl@0
|
926 |
{
|
sl@0
|
927 |
iGuard = 0;
|
sl@0
|
928 |
}
|
sl@0
|
929 |
|
sl@0
|
930 |
EXPORT_C TBool TCharFormatMask::operator==(const TCharFormatMask& aMask)const
|
sl@0
|
931 |
/** Compares two character format masks for equality.
|
sl@0
|
932 |
|
sl@0
|
933 |
@param aMask The mask to compare.
|
sl@0
|
934 |
@return ETrue if all flags are the same in both masks. EFalse if any differ. */
|
sl@0
|
935 |
{
|
sl@0
|
936 |
return (iGuard & KCharFormatBits) == (aMask.iGuard & KCharFormatBits);
|
sl@0
|
937 |
}
|