32
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <s32file.h>
|
|
20 |
#include <graphics/shapeimpl.h>
|
|
21 |
#include "FNTSTORE.H"
|
|
22 |
#include "OPENFONT.H"
|
|
23 |
#include "FNTBODY.H"
|
|
24 |
#include "FNTSTD.H"
|
|
25 |
#include <graphics/shaperparams.h>
|
|
26 |
#include "linkedfonts.h"
|
|
27 |
#include "linkedfontsprivate.h"
|
|
28 |
#include "openfontsprivate.h"
|
|
29 |
#include "fbs.h"
|
|
30 |
#include <openfontlinkedtypefaceelementspec.h>
|
|
31 |
#include <graphics/openfontlinkedtypefacespecification.h>
|
|
32 |
|
|
33 |
EXPORT_C CLinkedTypefaceSpecification* CLinkedTypefaceSpecification::NewLC(const TDesC& aTypefaceName)
|
|
34 |
{
|
|
35 |
CLinkedTypefaceSpecification* self = new (ELeave) CLinkedTypefaceSpecification();
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL(aTypefaceName);
|
|
38 |
return self;
|
|
39 |
}
|
|
40 |
|
|
41 |
CLinkedTypefaceSpecification::CLinkedTypefaceSpecification()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
void CLinkedTypefaceSpecification::ConstructL(const TDesC &aTypefaceName)
|
|
46 |
{
|
|
47 |
iBody = new (ELeave) CLinkedTypefaceSpecificationBody();
|
|
48 |
|
|
49 |
TInt length = aTypefaceName.Length();
|
|
50 |
if ((length > KMaxTypefaceNameLength) || (length == 0))
|
|
51 |
User::Leave(KErrArgument);
|
|
52 |
|
|
53 |
iBody->iLinkedTypefaceName = aTypefaceName.AllocL();
|
|
54 |
}
|
|
55 |
|
|
56 |
EXPORT_C void CLinkedTypefaceSpecification::AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex)
|
|
57 |
{
|
|
58 |
DoAddTypefaceL(aElementSpec, aIndex);
|
|
59 |
}
|
|
60 |
|
|
61 |
EXPORT_C void CLinkedTypefaceSpecification::AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec)
|
|
62 |
{
|
|
63 |
DoAddTypefaceL(aElementSpec, iBody->iTypefaces.Count());
|
|
64 |
}
|
|
65 |
|
|
66 |
EXPORT_C TInt CLinkedTypefaceSpecification::RemoveTypeface(TInt aIndex)
|
|
67 |
{
|
|
68 |
if ( (aIndex < iBody->iTypefaces.Count()) && (aIndex >= 0) )
|
|
69 |
{
|
|
70 |
CLinkedTypefaceElementSpec* elementSpec = iBody->iTypefaces[aIndex];
|
|
71 |
iBody->iTypefaces.Remove(aIndex);
|
|
72 |
delete elementSpec;
|
|
73 |
return KErrNone;
|
|
74 |
}
|
|
75 |
else
|
|
76 |
return KErrNotFound;
|
|
77 |
}
|
|
78 |
|
|
79 |
EXPORT_C void CLinkedTypefaceSpecification::RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore)
|
|
80 |
{
|
|
81 |
//Leave if there is no canonical element, or there are multiples.
|
|
82 |
//The remaining validation must be performed in fntstore.
|
|
83 |
User::LeaveIfError(CanonicalIndex());
|
|
84 |
User::LeaveIfError(aStore.RegisterLinkedTypeface(*this));
|
|
85 |
}
|
|
86 |
|
|
87 |
EXPORT_C void CLinkedTypefaceSpecification::FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore)
|
|
88 |
{
|
|
89 |
aStore.GetLinkedTypefaceL(*this);
|
|
90 |
}
|
|
91 |
|
|
92 |
EXPORT_C TInt CLinkedTypefaceSpecification::TypefaceCount() const
|
|
93 |
{
|
|
94 |
return iBody->iTypefaces.Count();
|
|
95 |
}
|
|
96 |
|
|
97 |
EXPORT_C TPtrC CLinkedTypefaceSpecification::Name() const
|
|
98 |
{
|
|
99 |
return *iBody->iLinkedTypefaceName;
|
|
100 |
}
|
|
101 |
|
|
102 |
EXPORT_C CLinkedTypefaceSpecification::~CLinkedTypefaceSpecification()
|
|
103 |
{
|
|
104 |
delete iBody;
|
|
105 |
}
|
|
106 |
|
|
107 |
EXPORT_C TInt CLinkedTypefaceSpecification::CanonicalIndex()
|
|
108 |
{
|
|
109 |
TInt index = KErrNotFound;
|
|
110 |
for (TInt i = iBody->iTypefaces.Count()-1 ; i >= 0; i--)
|
|
111 |
{
|
|
112 |
if (iBody->iTypefaces[i]->Canonical())
|
|
113 |
{
|
|
114 |
if (index == KErrNotFound)
|
|
115 |
index = i;
|
|
116 |
else
|
|
117 |
return KErrOverflow;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
return index;
|
|
121 |
}
|
|
122 |
|
|
123 |
EXPORT_C CLinkedTypefaceElementSpec* CLinkedTypefaceSpecification::Typeface(TInt aIndex) const
|
|
124 |
{
|
|
125 |
if ((aIndex >= iBody->iTypefaces.Count()) || (aIndex < 0))
|
|
126 |
{
|
|
127 |
return NULL;
|
|
128 |
}
|
|
129 |
else
|
|
130 |
{
|
|
131 |
return iBody->iTypefaces[aIndex];
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
void CLinkedTypefaceSpecification::DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos)
|
|
136 |
{
|
|
137 |
if (iBody->iTypefaces.Count() == KMaxLinkedTypefaces)
|
|
138 |
User::Leave(KErrOverflow);
|
|
139 |
|
|
140 |
TInt err = iBody->iTypefaces.Find(&aElementSpec);
|
|
141 |
|
|
142 |
if (err != KErrNotFound)
|
|
143 |
User::Leave(KErrAlreadyExists);
|
|
144 |
|
|
145 |
if (aElementSpec.Canonical() && CanonicalIndex() != KErrNotFound)
|
|
146 |
User::Leave(KErrArgument);
|
|
147 |
|
|
148 |
if (GroupById(aElementSpec.GroupId()) == NULL)
|
|
149 |
User::Leave(KErrArgument);
|
|
150 |
|
|
151 |
err = iBody->iTypefaces.Insert(&aElementSpec, aPos);
|
|
152 |
|
|
153 |
User::LeaveIfError(err);
|
|
154 |
}
|
|
155 |
|
|
156 |
EXPORT_C void CLinkedTypefaceSpecification::AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup)
|
|
157 |
{
|
|
158 |
if (iBody->iGroups.Count() == KMaxLinkedTypefaceGroups)
|
|
159 |
User::Leave(KErrOverflow);
|
|
160 |
|
|
161 |
for (TInt i = iBody->iGroups.Count()-1 ; i >= 0 ; i--)
|
|
162 |
{
|
|
163 |
if (iBody->iGroups[i]->GroupId() == aGroup.GroupId())
|
|
164 |
User::Leave(KErrAlreadyExists);
|
|
165 |
}
|
|
166 |
iBody->iGroups.AppendL(&aGroup);
|
|
167 |
}
|
|
168 |
|
|
169 |
EXPORT_C TInt CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup(TInt aGroupId)
|
|
170 |
{
|
|
171 |
//Search for & remove the group if it exists
|
|
172 |
CLinkedTypefaceGroup* remove = GroupById(aGroupId);
|
|
173 |
//If the group has been found & removed remove all associated typefaces
|
|
174 |
if (remove)
|
|
175 |
{
|
|
176 |
CLinkedTypefaceElementSpec* elementSpec;
|
|
177 |
for (TInt i = iBody->iTypefaces.Count()-1 ; i >= 0 ; i--)
|
|
178 |
{
|
|
179 |
elementSpec = iBody->iTypefaces[i];
|
|
180 |
if (elementSpec->GroupId() == aGroupId)
|
|
181 |
RemoveTypeface(i);
|
|
182 |
}
|
|
183 |
iBody->iGroups.Remove(iBody->iGroups.Find(remove));
|
|
184 |
delete remove;
|
|
185 |
return KErrNone;
|
|
186 |
}
|
|
187 |
return KErrNotFound;
|
|
188 |
}
|
|
189 |
|
|
190 |
EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceSpecification::GroupById(TInt aGroupId) const
|
|
191 |
{
|
|
192 |
TInt index;
|
|
193 |
TBool found = EFalse;
|
|
194 |
for (index = iBody->iGroups.Count()-1; index != -1 ; index--)
|
|
195 |
{
|
|
196 |
if (iBody->iGroups[index]->GroupId() == aGroupId)
|
|
197 |
{
|
|
198 |
found = ETrue;
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
|
|
203 |
if (found)
|
|
204 |
return iBody->iGroups[index];
|
|
205 |
else
|
|
206 |
return NULL;
|
|
207 |
}
|
|
208 |
|
|
209 |
EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceSpecification::Group(TInt aGroupIndex) const
|
|
210 |
{
|
|
211 |
if ( (aGroupIndex >= 0) && (aGroupIndex < iBody->iGroups.Count()) )
|
|
212 |
return iBody->iGroups[aGroupIndex];
|
|
213 |
else
|
|
214 |
return NULL;
|
|
215 |
}
|
|
216 |
|
|
217 |
EXPORT_C TInt CLinkedTypefaceSpecification::GroupCount() const
|
|
218 |
{
|
|
219 |
return iBody->iGroups.Count();
|
|
220 |
}
|
|
221 |
|
|
222 |
EXPORT_C void CLinkedTypefaceSpecification::Clear()
|
|
223 |
{
|
|
224 |
iBody->iGroups.ResetAndDestroy();
|
|
225 |
iBody->iTypefaces.ResetAndDestroy();
|
|
226 |
}
|
|
227 |
|
|
228 |
EXPORT_C void CLinkedTypefaceSpecification::UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore)
|
|
229 |
{
|
|
230 |
User::LeaveIfError(aStore.UpdateLinkedTypeface(*this));
|
|
231 |
}
|
|
232 |
|
|
233 |
CLinkedTypefaceSpecificationBody::CLinkedTypefaceSpecificationBody()
|
|
234 |
{
|
|
235 |
}
|
|
236 |
|
|
237 |
CLinkedTypefaceSpecificationBody::~CLinkedTypefaceSpecificationBody()
|
|
238 |
{
|
|
239 |
delete iLinkedTypefaceName;
|
|
240 |
iTypefaces.ResetAndDestroy();
|
|
241 |
iGroups.ResetAndDestroy();
|
|
242 |
}
|
|
243 |
|
|
244 |
EXPORT_C CLinkedTypefaceElementSpec* CLinkedTypefaceElementSpec::NewLC(const TDesC& aElementName, TInt aGroupId)
|
|
245 |
{
|
|
246 |
CLinkedTypefaceElementSpec* self = new(ELeave)CLinkedTypefaceElementSpec(aGroupId);
|
|
247 |
CleanupStack::PushL(self);
|
|
248 |
self->ConstructL(aElementName);
|
|
249 |
return self;
|
|
250 |
}
|
|
251 |
|
|
252 |
EXPORT_C CLinkedTypefaceElementSpec::~CLinkedTypefaceElementSpec()
|
|
253 |
{
|
|
254 |
delete iElementName;
|
|
255 |
}
|
|
256 |
|
|
257 |
EXPORT_C TPtrC CLinkedTypefaceElementSpec::ElementName() const
|
|
258 |
{
|
|
259 |
return *iElementName;
|
|
260 |
}
|
|
261 |
|
|
262 |
EXPORT_C void CLinkedTypefaceElementSpec::SetCanonical(TBool aIsCanonical)
|
|
263 |
{
|
|
264 |
iIsCanonical = aIsCanonical;
|
|
265 |
}
|
|
266 |
|
|
267 |
EXPORT_C TBool CLinkedTypefaceElementSpec::Canonical() const
|
|
268 |
{
|
|
269 |
return iIsCanonical;
|
|
270 |
}
|
|
271 |
|
|
272 |
CLinkedTypefaceElementSpec::CLinkedTypefaceElementSpec(TInt aGroupId)
|
|
273 |
{
|
|
274 |
iGroupId = aGroupId;
|
|
275 |
iIsCanonical = EFalse;
|
|
276 |
}
|
|
277 |
|
|
278 |
EXPORT_C TInt CLinkedTypefaceElementSpec::GroupId() const
|
|
279 |
{
|
|
280 |
return iGroupId;
|
|
281 |
}
|
|
282 |
|
|
283 |
EXPORT_C COpenFontLinkedTypefaceSpecification* COpenFontLinkedTypefaceSpecification::NewLC(const TDesC& aTypefaceName)
|
|
284 |
{
|
|
285 |
COpenFontLinkedTypefaceSpecification* self = new (ELeave) COpenFontLinkedTypefaceSpecification();
|
|
286 |
CleanupStack::PushL(self);
|
|
287 |
self->ConstructL(aTypefaceName);
|
|
288 |
return self;
|
|
289 |
}
|
|
290 |
|
|
291 |
EXPORT_C COpenFontLinkedTypefaceSpecification* COpenFontLinkedTypefaceSpecification::NewLC(const TLinkedTypefaceSpecificationArgs& aSpecArgs)
|
|
292 |
{
|
|
293 |
COpenFontLinkedTypefaceSpecification* self = new (ELeave) COpenFontLinkedTypefaceSpecification();
|
|
294 |
CleanupStack::PushL(self);
|
|
295 |
self->ConstructL(aSpecArgs);
|
|
296 |
return self;
|
|
297 |
}
|
|
298 |
|
|
299 |
COpenFontLinkedTypefaceSpecification::COpenFontLinkedTypefaceSpecification()
|
|
300 |
{
|
|
301 |
}
|
|
302 |
|
|
303 |
void COpenFontLinkedTypefaceSpecification::ConstructL(const TDesC &aTypefaceName)
|
|
304 |
{
|
|
305 |
TInt length = aTypefaceName.Length();
|
|
306 |
if ((length > KMaxTypefaceNameLength) || (length == 0))
|
|
307 |
User::Leave(KErrArgument);
|
|
308 |
|
|
309 |
iLinkedTypefaceName = aTypefaceName.AllocL();
|
|
310 |
}
|
|
311 |
|
|
312 |
void COpenFontLinkedTypefaceSpecification::ConstructL(const TLinkedTypefaceSpecificationArgs& aSpecArgs)
|
|
313 |
{
|
|
314 |
iLinkedTypefaceName = aSpecArgs.iName.AllocL();
|
|
315 |
|
|
316 |
TInt i;
|
|
317 |
|
|
318 |
for (i = 0; i != aSpecArgs.iGroupSize ; i++)
|
|
319 |
{
|
|
320 |
CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(aSpecArgs.iGroups[i].iGroupId);
|
|
321 |
grp->SetBaselineShift(aSpecArgs.iGroups[i].iBaselineShift);
|
|
322 |
grp->SetBoldnessPercentage(aSpecArgs.iGroups[i].iBoldnessPercentage);
|
|
323 |
grp->SetItalicAngle(aSpecArgs.iGroups[i].iItalicAngle);
|
|
324 |
grp->SetScalingOption(aSpecArgs.iGroups[i].iScalingOption);
|
|
325 |
AddLinkedTypefaceGroupL(*grp);
|
|
326 |
CleanupStack::Pop(grp);
|
|
327 |
}
|
|
328 |
|
|
329 |
for (i = 0 ; i != aSpecArgs.iSize ; i++)
|
|
330 |
{
|
|
331 |
COpenFontLinkedTypefaceElementSpec* es = COpenFontLinkedTypefaceElementSpec::NewLC(aSpecArgs.iTypefaces[i].iName, aSpecArgs.iTypefaces[i].iGroupId);
|
|
332 |
es->SetCanonical(aSpecArgs.iTypefaces[i].iIsCanonical);
|
|
333 |
AddTypefaceAtBackL(*es);
|
|
334 |
CleanupStack::Pop(es);
|
|
335 |
}
|
|
336 |
|
|
337 |
//ASSERT Can. Indexs match.
|
|
338 |
}
|
|
339 |
|
|
340 |
EXPORT_C COpenFontLinkedTypefaceSpecification::~COpenFontLinkedTypefaceSpecification()
|
|
341 |
{
|
|
342 |
delete iLinkedTypefaceName;
|
|
343 |
iTypefaces.ResetAndDestroy();
|
|
344 |
iTypefaces.Close();
|
|
345 |
iGroups.ResetAndDestroy();
|
|
346 |
iGroups.Close();
|
|
347 |
}
|
|
348 |
|
|
349 |
EXPORT_C void COpenFontLinkedTypefaceSpecification::AddTypefaceAtIndexL(COpenFontLinkedTypefaceElementSpec& aElementSpec, TInt aIndex)
|
|
350 |
{
|
|
351 |
DoAddTypefaceL(aElementSpec, aIndex);
|
|
352 |
}
|
|
353 |
|
|
354 |
EXPORT_C void COpenFontLinkedTypefaceSpecification::AddTypefaceAtBackL(COpenFontLinkedTypefaceElementSpec& aElementSpec)
|
|
355 |
{
|
|
356 |
DoAddTypefaceL(aElementSpec, iTypefaces.Count());
|
|
357 |
}
|
|
358 |
|
|
359 |
EXPORT_C TInt COpenFontLinkedTypefaceSpecification::RemoveTypeface(TInt aIndex)
|
|
360 |
{
|
|
361 |
if ( (aIndex < iTypefaces.Count()) && (aIndex >= 0) )
|
|
362 |
{
|
|
363 |
COpenFontLinkedTypefaceElementSpec* elementSpec = iTypefaces[aIndex];
|
|
364 |
iTypefaces.Remove(aIndex);
|
|
365 |
|
|
366 |
delete elementSpec;
|
|
367 |
return KErrNone;
|
|
368 |
}
|
|
369 |
else
|
|
370 |
return KErrNotFound;
|
|
371 |
}
|
|
372 |
|
|
373 |
EXPORT_C TInt COpenFontLinkedTypefaceSpecification::TypefaceCount() const
|
|
374 |
{
|
|
375 |
return iTypefaces.Count();
|
|
376 |
}
|
|
377 |
|
|
378 |
EXPORT_C TPtrC COpenFontLinkedTypefaceSpecification::Name() const
|
|
379 |
{
|
|
380 |
return *iLinkedTypefaceName;
|
|
381 |
}
|
|
382 |
|
|
383 |
EXPORT_C TInt COpenFontLinkedTypefaceSpecification::CanonicalIndex() const
|
|
384 |
{
|
|
385 |
TInt index = KErrNotFound;
|
|
386 |
for (TInt i = iTypefaces.Count()-1 ; i >= 0; i--)
|
|
387 |
{
|
|
388 |
if (iTypefaces[i]->Canonical())
|
|
389 |
{
|
|
390 |
if (index == KErrNotFound)
|
|
391 |
index = i;
|
|
392 |
else
|
|
393 |
return KErrOverflow;
|
|
394 |
}
|
|
395 |
}
|
|
396 |
return index;
|
|
397 |
}
|
|
398 |
|
|
399 |
EXPORT_C COpenFontLinkedTypefaceElementSpec* COpenFontLinkedTypefaceSpecification::Typeface(TInt aIndex) const
|
|
400 |
{
|
|
401 |
if ((aIndex >= iTypefaces.Count()) || (aIndex < 0))
|
|
402 |
{
|
|
403 |
return NULL;
|
|
404 |
}
|
|
405 |
else
|
|
406 |
{
|
|
407 |
return iTypefaces[aIndex];
|
|
408 |
}
|
|
409 |
}
|
|
410 |
|
|
411 |
void COpenFontLinkedTypefaceSpecification::DoAddTypefaceL(COpenFontLinkedTypefaceElementSpec& aElementSpec, TInt aPos)
|
|
412 |
{
|
|
413 |
if (iTypefaces.Count() == KMaxLinkedTypefaces)
|
|
414 |
User::Leave(KErrOverflow);
|
|
415 |
|
|
416 |
TInt err = iTypefaces.Find(&aElementSpec);
|
|
417 |
|
|
418 |
if (err != KErrNotFound)
|
|
419 |
User::Leave(KErrAlreadyExists);
|
|
420 |
|
|
421 |
if (aElementSpec.Canonical() && CanonicalIndex() >= 0)
|
|
422 |
User::Leave(KErrArgument);
|
|
423 |
|
|
424 |
if (GroupById(aElementSpec.GroupId()) == NULL)
|
|
425 |
User::Leave(KErrArgument);
|
|
426 |
|
|
427 |
err = iTypefaces.Insert(&aElementSpec, aPos);
|
|
428 |
|
|
429 |
User::LeaveIfError(err);
|
|
430 |
}
|
|
431 |
|
|
432 |
EXPORT_C void COpenFontLinkedTypefaceSpecification::AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup)
|
|
433 |
{
|
|
434 |
if (iGroups.Count() == KMaxLinkedTypefaceGroups)
|
|
435 |
User::Leave(KErrOverflow);
|
|
436 |
|
|
437 |
for (TInt i = iGroups.Count()-1 ; i >= 0 ; i--)
|
|
438 |
{
|
|
439 |
if (iGroups[i]->GroupId() == aGroup.GroupId())
|
|
440 |
User::Leave(KErrAlreadyExists);
|
|
441 |
}
|
|
442 |
iGroups.AppendL(&aGroup);
|
|
443 |
}
|
|
444 |
|
|
445 |
EXPORT_C TInt COpenFontLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup(TInt aGroupId)
|
|
446 |
{
|
|
447 |
//Search for & remove the group if it exists
|
|
448 |
CLinkedTypefaceGroup* remove = GroupById(aGroupId);
|
|
449 |
//If the group has been found & removed remove all associated typefaces
|
|
450 |
if (remove)
|
|
451 |
{
|
|
452 |
COpenFontLinkedTypefaceElementSpec* elementSpec;
|
|
453 |
for (TInt i = iTypefaces.Count()-1 ; i >= 0 ; i--)
|
|
454 |
{
|
|
455 |
elementSpec = iTypefaces[i];
|
|
456 |
if (elementSpec->GroupId() == aGroupId)
|
|
457 |
RemoveTypeface(i);
|
|
458 |
}
|
|
459 |
iGroups.Remove(iGroups.Find(remove));
|
|
460 |
delete remove;
|
|
461 |
return KErrNone;
|
|
462 |
}
|
|
463 |
return KErrNotFound;
|
|
464 |
}
|
|
465 |
|
|
466 |
EXPORT_C CLinkedTypefaceGroup* COpenFontLinkedTypefaceSpecification::GroupById(TInt aGroupId) const
|
|
467 |
{
|
|
468 |
TInt index;
|
|
469 |
TBool found = EFalse;
|
|
470 |
for (index = iGroups.Count()-1; index != -1 ; index--)
|
|
471 |
{
|
|
472 |
if (iGroups[index]->GroupId() == aGroupId)
|
|
473 |
{
|
|
474 |
found = ETrue;
|
|
475 |
break;
|
|
476 |
}
|
|
477 |
}
|
|
478 |
|
|
479 |
if (found)
|
|
480 |
return iGroups[index];
|
|
481 |
else
|
|
482 |
return NULL;
|
|
483 |
}
|
|
484 |
|
|
485 |
EXPORT_C const CLinkedTypefaceGroup* COpenFontLinkedTypefaceSpecification::Group(TInt aGroupIndex) const
|
|
486 |
{
|
|
487 |
if ( (aGroupIndex >= 0) && (aGroupIndex < iGroups.Count()) )
|
|
488 |
return iGroups[aGroupIndex];
|
|
489 |
else
|
|
490 |
return NULL;
|
|
491 |
}
|
|
492 |
|
|
493 |
EXPORT_C TInt COpenFontLinkedTypefaceSpecification::GroupCount() const
|
|
494 |
{
|
|
495 |
return iGroups.Count();
|
|
496 |
}
|
|
497 |
|
|
498 |
COpenFontLinkedTypefaceSpecificationBody::COpenFontLinkedTypefaceSpecificationBody()
|
|
499 |
{
|
|
500 |
}
|
|
501 |
|
|
502 |
// destructor
|
|
503 |
COpenFontLinkedTypefaceSpecificationBody::~COpenFontLinkedTypefaceSpecificationBody()
|
|
504 |
{
|
|
505 |
delete iLinkedTypefaceName;
|
|
506 |
iTypefaces.Reset();
|
|
507 |
}
|
|
508 |
|
|
509 |
EXPORT_C COpenFontLinkedTypefaceElementSpec* COpenFontLinkedTypefaceElementSpec::NewLC(const TDesC& aElementName, TInt aGroupId)
|
|
510 |
{
|
|
511 |
COpenFontLinkedTypefaceElementSpec* self = new(ELeave)COpenFontLinkedTypefaceElementSpec(aGroupId);
|
|
512 |
CleanupStack::PushL(self);
|
|
513 |
self->ConstructL(aElementName);
|
|
514 |
return self;
|
|
515 |
}
|
|
516 |
|
|
517 |
EXPORT_C COpenFontLinkedTypefaceElementSpec::~COpenFontLinkedTypefaceElementSpec()
|
|
518 |
{
|
|
519 |
delete iElementName;
|
|
520 |
delete iFileName;
|
|
521 |
}
|
|
522 |
|
|
523 |
EXPORT_C TPtrC COpenFontLinkedTypefaceElementSpec::ElementName() const
|
|
524 |
{
|
|
525 |
return *iElementName;
|
|
526 |
}
|
|
527 |
|
|
528 |
EXPORT_C void COpenFontLinkedTypefaceElementSpec::SetCanonical(TBool aIsCanonical)
|
|
529 |
{
|
|
530 |
iIsCanonical = aIsCanonical;
|
|
531 |
}
|
|
532 |
|
|
533 |
EXPORT_C TBool COpenFontLinkedTypefaceElementSpec::Canonical() const
|
|
534 |
{
|
|
535 |
return iIsCanonical;
|
|
536 |
}
|
|
537 |
|
|
538 |
EXPORT_C TInt COpenFontLinkedTypefaceElementSpec::GroupId() const
|
|
539 |
{
|
|
540 |
return iGroupId;
|
|
541 |
}
|
|
542 |
|
|
543 |
EXPORT_C TPtrC COpenFontLinkedTypefaceElementSpec::FileName() const
|
|
544 |
{
|
|
545 |
return *iFileName;
|
|
546 |
}
|
|
547 |
|
|
548 |
EXPORT_C void COpenFontLinkedTypefaceElementSpec::SetFileNameL(const TDesC& aFileName)
|
|
549 |
{
|
|
550 |
iFileName = aFileName.AllocL();
|
|
551 |
}
|
|
552 |
|
|
553 |
COpenFontLinkedTypefaceElementSpec::COpenFontLinkedTypefaceElementSpec(TInt aGroupId)
|
|
554 |
{
|
|
555 |
iGroupId = aGroupId;
|
|
556 |
}
|
|
557 |
|
|
558 |
void COpenFontLinkedTypefaceElementSpec::ConstructL(const TDesC& aName)
|
|
559 |
{
|
|
560 |
TInt length = aName.Length();
|
|
561 |
if ((length == 0) || (length > KMaxTypefaceNameLength))
|
|
562 |
User::Leave(KErrArgument);
|
|
563 |
iElementName = aName.AllocL();
|
|
564 |
}
|
|
565 |
|
|
566 |
void CLinkedTypefaceElementSpec::ConstructL(const TDesC& aName)
|
|
567 |
{
|
|
568 |
TInt length = aName.Length();
|
|
569 |
if ((length == 0) || (length > KMaxTypefaceNameLength))
|
|
570 |
User::Leave(KErrArgument);
|
|
571 |
iElementName = aName.AllocL();
|
|
572 |
}
|
|
573 |
|
|
574 |
EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceGroup::NewLC(TInt aGroupId)
|
|
575 |
{
|
|
576 |
CLinkedTypefaceGroup* self = new (ELeave) CLinkedTypefaceGroup(aGroupId);
|
|
577 |
CleanupStack::PushL(self);
|
|
578 |
return self;
|
|
579 |
}
|
|
580 |
|
|
581 |
CLinkedTypefaceGroup::CLinkedTypefaceGroup(TInt aGroupId)
|
|
582 |
{
|
|
583 |
iGroupId = aGroupId;
|
|
584 |
iScalingOption = EScalingNone;
|
|
585 |
iBaselineShift = ENoBaselineShift;
|
|
586 |
iBoldnessPercentage = -1;
|
|
587 |
iItalicAngle = -1;
|
|
588 |
}
|
|
589 |
|
|
590 |
CLinkedTypefaceGroup::~CLinkedTypefaceGroup()
|
|
591 |
{
|
|
592 |
}
|
|
593 |
|
|
594 |
EXPORT_C void CLinkedTypefaceGroup::SetScalingOption(CLinkedTypefaceGroup::TScalingOption aOption)
|
|
595 |
{
|
|
596 |
iScalingOption = aOption;
|
|
597 |
}
|
|
598 |
|
|
599 |
EXPORT_C CLinkedTypefaceGroup::TScalingOption CLinkedTypefaceGroup::ScalingOption() const
|
|
600 |
{
|
|
601 |
return iScalingOption;
|
|
602 |
}
|
|
603 |
|
|
604 |
EXPORT_C void CLinkedTypefaceGroup::SetBaselineShift(CLinkedTypefaceGroup::TBaselineShift aShift)
|
|
605 |
{
|
|
606 |
iBaselineShift = aShift;
|
|
607 |
}
|
|
608 |
|
|
609 |
EXPORT_C CLinkedTypefaceGroup::TBaselineShift CLinkedTypefaceGroup::BaselineShift() const
|
|
610 |
{
|
|
611 |
return iBaselineShift;
|
|
612 |
}
|
|
613 |
|
|
614 |
EXPORT_C void CLinkedTypefaceGroup::SetBoldnessPercentage(TInt aPercentage)
|
|
615 |
{
|
|
616 |
iBoldnessPercentage = aPercentage;
|
|
617 |
}
|
|
618 |
|
|
619 |
EXPORT_C TInt CLinkedTypefaceGroup::BoldnessPercentage() const
|
|
620 |
{
|
|
621 |
return iBoldnessPercentage;
|
|
622 |
}
|
|
623 |
|
|
624 |
EXPORT_C TInt CLinkedTypefaceGroup::GroupId() const
|
|
625 |
{
|
|
626 |
return iGroupId;
|
|
627 |
}
|
|
628 |
|
|
629 |
EXPORT_C TInt CLinkedTypefaceGroup::ItalicAngle() const
|
|
630 |
{
|
|
631 |
return iItalicAngle;
|
|
632 |
}
|
|
633 |
|
|
634 |
EXPORT_C void CLinkedTypefaceGroup::SetItalicAngle(TInt aAngle)
|
|
635 |
{
|
|
636 |
iItalicAngle = aAngle;
|
|
637 |
}
|
|
638 |
|
|
639 |
EXPORT_C void TLinkedTypefaceSpecificationArgs::operator =(const CLinkedTypefaceSpecification& aRhs)
|
|
640 |
{
|
|
641 |
iSize = aRhs.TypefaceCount();
|
|
642 |
iGroupSize = aRhs.GroupCount();
|
|
643 |
iName = aRhs.Name();
|
|
644 |
|
|
645 |
TInt i;
|
|
646 |
for (i = 0 ; i != iSize ; i++)
|
|
647 |
iTypefaces[i] = aRhs.Typeface(i);
|
|
648 |
|
|
649 |
for (i = 0 ; i != iGroupSize ; i++)
|
|
650 |
iGroups[i] = aRhs.Group(i);
|
|
651 |
}
|
|
652 |
|
|
653 |
EXPORT_C void TLinkedTypefaceSpecificationArgs::operator =(const COpenFontLinkedTypefaceSpecification &aRhs)
|
|
654 |
{
|
|
655 |
iSize = aRhs.TypefaceCount();
|
|
656 |
iGroupSize = aRhs.GroupCount();
|
|
657 |
iName = aRhs.Name();
|
|
658 |
|
|
659 |
TInt i;
|
|
660 |
for (i = 0 ; i != iSize ; i++)
|
|
661 |
iTypefaces[i] = aRhs.Typeface(i);
|
|
662 |
|
|
663 |
for (i = 0 ; i != iGroupSize ; i++)
|
|
664 |
iGroups[i] = aRhs.Group(i);
|
|
665 |
}
|
|
666 |
|
|
667 |
void TLinkedTypefaceElementSpecArgs::operator = (const CLinkedTypefaceElementSpec* aRhs)
|
|
668 |
{
|
|
669 |
iIsCanonical = aRhs->Canonical();
|
|
670 |
iGroupId = aRhs->GroupId();
|
|
671 |
iName = aRhs->ElementName();
|
|
672 |
}
|
|
673 |
|
|
674 |
void TLinkedTypefaceElementSpecArgs::operator = (const COpenFontLinkedTypefaceElementSpec* aRhs)
|
|
675 |
{
|
|
676 |
iIsCanonical = aRhs->Canonical();
|
|
677 |
iGroupId = aRhs->GroupId();
|
|
678 |
iName = aRhs->ElementName();
|
|
679 |
}
|
|
680 |
|
|
681 |
void TLinkedTypefaceGroupArgs::operator =(const CLinkedTypefaceGroup* aRhs)
|
|
682 |
{
|
|
683 |
iGroupId = aRhs->GroupId();
|
|
684 |
iScalingOption = aRhs->ScalingOption();
|
|
685 |
iBaselineShift = aRhs->BaselineShift();
|
|
686 |
iBoldnessPercentage = aRhs->BoldnessPercentage();
|
|
687 |
iItalicAngle = aRhs->ItalicAngle();
|
|
688 |
}
|