os/textandloc/fontservices/fontstore/src/linkedfonts.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/fontstore/src/linkedfonts.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,688 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-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 "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.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 +
    1.21 +
    1.22 +#include <s32file.h>
    1.23 +#include <graphics/shapeimpl.h>
    1.24 +#include "FNTSTORE.H"
    1.25 +#include "OPENFONT.H"
    1.26 +#include "FNTBODY.H"
    1.27 +#include "FNTSTD.H"
    1.28 +#include <graphics/shaperparams.h>
    1.29 +#include "linkedfonts.h"
    1.30 +#include "linkedfontsprivate.h"
    1.31 +#include "openfontsprivate.h"
    1.32 +#include "fbs.h"
    1.33 +#include <openfontlinkedtypefaceelementspec.h>
    1.34 +#include <graphics/openfontlinkedtypefacespecification.h>
    1.35 +
    1.36 +EXPORT_C CLinkedTypefaceSpecification* CLinkedTypefaceSpecification::NewLC(const TDesC& aTypefaceName)
    1.37 +	{
    1.38 +	CLinkedTypefaceSpecification* self = new (ELeave) CLinkedTypefaceSpecification();
    1.39 +	CleanupStack::PushL(self);
    1.40 +	self->ConstructL(aTypefaceName);
    1.41 +	return self;
    1.42 +	}
    1.43 +
    1.44 +CLinkedTypefaceSpecification::CLinkedTypefaceSpecification()
    1.45 +	{
    1.46 +	}
    1.47 +
    1.48 +void CLinkedTypefaceSpecification::ConstructL(const TDesC &aTypefaceName)
    1.49 +	{
    1.50 +	iBody = new (ELeave) CLinkedTypefaceSpecificationBody();
    1.51 +
    1.52 +	TInt length = aTypefaceName.Length();
    1.53 +	if ((length > KMaxTypefaceNameLength) || (length == 0))
    1.54 +		User::Leave(KErrArgument);
    1.55 +
    1.56 +	iBody->iLinkedTypefaceName = aTypefaceName.AllocL();
    1.57 +	}
    1.58 +
    1.59 +EXPORT_C void CLinkedTypefaceSpecification::AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex)
    1.60 +	{
    1.61 +	DoAddTypefaceL(aElementSpec, aIndex);
    1.62 +	}
    1.63 +
    1.64 +EXPORT_C void CLinkedTypefaceSpecification::AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec)
    1.65 +	{
    1.66 +	DoAddTypefaceL(aElementSpec, iBody->iTypefaces.Count());
    1.67 +	}
    1.68 +
    1.69 +EXPORT_C TInt CLinkedTypefaceSpecification::RemoveTypeface(TInt aIndex)
    1.70 +	{
    1.71 +	if  ( (aIndex < iBody->iTypefaces.Count()) && (aIndex >= 0) )
    1.72 +		{
    1.73 +		CLinkedTypefaceElementSpec* elementSpec = iBody->iTypefaces[aIndex];
    1.74 +		iBody->iTypefaces.Remove(aIndex);
    1.75 +		delete elementSpec;
    1.76 +		return KErrNone;
    1.77 +		}
    1.78 +	else
    1.79 +		return KErrNotFound;
    1.80 +	}
    1.81 +
    1.82 +EXPORT_C void CLinkedTypefaceSpecification::RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore)
    1.83 +	{
    1.84 +	//Leave if there is no canonical element, or there are multiples.
    1.85 +	//The remaining validation must be performed in fntstore.
    1.86 +	User::LeaveIfError(CanonicalIndex());
    1.87 +	User::LeaveIfError(aStore.RegisterLinkedTypeface(*this));
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C void CLinkedTypefaceSpecification::FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore)
    1.91 +	{	
    1.92 +	aStore.GetLinkedTypefaceL(*this);
    1.93 +	}
    1.94 +
    1.95 +EXPORT_C TInt CLinkedTypefaceSpecification::TypefaceCount() const
    1.96 +	{
    1.97 +	return iBody->iTypefaces.Count();
    1.98 +	}
    1.99 +
   1.100 +EXPORT_C TPtrC CLinkedTypefaceSpecification::Name() const
   1.101 +	{
   1.102 +	return *iBody->iLinkedTypefaceName;
   1.103 +	}
   1.104 +
   1.105 +EXPORT_C CLinkedTypefaceSpecification::~CLinkedTypefaceSpecification()
   1.106 +	{
   1.107 +	delete iBody;
   1.108 +	}
   1.109 +
   1.110 +EXPORT_C TInt CLinkedTypefaceSpecification::CanonicalIndex()
   1.111 +	{
   1.112 +	TInt index = KErrNotFound;
   1.113 +	for (TInt i = iBody->iTypefaces.Count()-1 ; i >= 0; i--)
   1.114 +		{
   1.115 +		if (iBody->iTypefaces[i]->Canonical())
   1.116 +			{
   1.117 +			if (index == KErrNotFound)
   1.118 +				index = i;
   1.119 +			else 
   1.120 +				return KErrOverflow;
   1.121 +			}
   1.122 +		}
   1.123 +	return index;
   1.124 +	}
   1.125 +
   1.126 +EXPORT_C CLinkedTypefaceElementSpec* CLinkedTypefaceSpecification::Typeface(TInt aIndex) const
   1.127 +	{
   1.128 +	if ((aIndex >= iBody->iTypefaces.Count()) || (aIndex < 0))
   1.129 +		{
   1.130 +		return NULL;
   1.131 +		}
   1.132 +	else
   1.133 +		{
   1.134 +		return iBody->iTypefaces[aIndex];
   1.135 +		}
   1.136 +	}
   1.137 +
   1.138 +void CLinkedTypefaceSpecification::DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos)
   1.139 +	{
   1.140 +	if (iBody->iTypefaces.Count() == KMaxLinkedTypefaces)
   1.141 +		User::Leave(KErrOverflow);
   1.142 +	
   1.143 +	TInt err = iBody->iTypefaces.Find(&aElementSpec);
   1.144 +
   1.145 +	if (err != KErrNotFound)
   1.146 +		User::Leave(KErrAlreadyExists);
   1.147 +	
   1.148 +	if (aElementSpec.Canonical() && CanonicalIndex() != KErrNotFound)
   1.149 +		User::Leave(KErrArgument);
   1.150 +
   1.151 +	if (GroupById(aElementSpec.GroupId()) == NULL)
   1.152 +		User::Leave(KErrArgument);
   1.153 +	
   1.154 +	err = iBody->iTypefaces.Insert(&aElementSpec, aPos);
   1.155 +
   1.156 +	User::LeaveIfError(err);
   1.157 +	}
   1.158 +
   1.159 +EXPORT_C void CLinkedTypefaceSpecification::AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup)
   1.160 +	{
   1.161 +	if (iBody->iGroups.Count() == KMaxLinkedTypefaceGroups)
   1.162 +		User::Leave(KErrOverflow);
   1.163 +	
   1.164 +	for (TInt i = iBody->iGroups.Count()-1 ; i >= 0 ; i--)
   1.165 +		{
   1.166 +		if (iBody->iGroups[i]->GroupId() == aGroup.GroupId())
   1.167 +			User::Leave(KErrAlreadyExists);
   1.168 +		}
   1.169 +	iBody->iGroups.AppendL(&aGroup);
   1.170 +	}
   1.171 +
   1.172 +EXPORT_C TInt CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup(TInt aGroupId)
   1.173 +	{
   1.174 +	//Search for & remove the group if it exists
   1.175 +	CLinkedTypefaceGroup* remove = GroupById(aGroupId);
   1.176 +	//If the group has been found & removed remove all associated typefaces
   1.177 +	if (remove)
   1.178 +		{
   1.179 +		CLinkedTypefaceElementSpec* elementSpec;
   1.180 +		for (TInt i = iBody->iTypefaces.Count()-1 ; i >= 0 ; i--)
   1.181 +			{
   1.182 +			elementSpec = iBody->iTypefaces[i];
   1.183 +			if (elementSpec->GroupId() == aGroupId)
   1.184 +				RemoveTypeface(i);
   1.185 +			}
   1.186 +		iBody->iGroups.Remove(iBody->iGroups.Find(remove));
   1.187 +		delete remove;
   1.188 +		return KErrNone;
   1.189 +		}
   1.190 +	return KErrNotFound;
   1.191 +	}
   1.192 +
   1.193 +EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceSpecification::GroupById(TInt aGroupId) const
   1.194 +	{
   1.195 +	TInt index;
   1.196 +	TBool found = EFalse;
   1.197 +	for (index = iBody->iGroups.Count()-1; index != -1 ; index--)
   1.198 +		{
   1.199 +		if (iBody->iGroups[index]->GroupId() == aGroupId)
   1.200 +			{
   1.201 +			found = ETrue;
   1.202 +			break;
   1.203 +			}
   1.204 +		}
   1.205 +	
   1.206 +	if (found)
   1.207 +		return iBody->iGroups[index];
   1.208 +	else
   1.209 +		return NULL;
   1.210 +	}
   1.211 +
   1.212 +EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceSpecification::Group(TInt aGroupIndex) const
   1.213 +	{
   1.214 +	if ( (aGroupIndex >= 0) && (aGroupIndex < iBody->iGroups.Count()) )
   1.215 +		return iBody->iGroups[aGroupIndex];
   1.216 +	else
   1.217 +		return NULL;
   1.218 +	}
   1.219 +
   1.220 +EXPORT_C TInt CLinkedTypefaceSpecification::GroupCount() const
   1.221 +	{
   1.222 +	return iBody->iGroups.Count();
   1.223 +	}
   1.224 +
   1.225 +EXPORT_C void CLinkedTypefaceSpecification::Clear()
   1.226 +	{
   1.227 +	iBody->iGroups.ResetAndDestroy();
   1.228 +	iBody->iTypefaces.ResetAndDestroy();
   1.229 +	}
   1.230 +
   1.231 +EXPORT_C void CLinkedTypefaceSpecification::UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore)
   1.232 +	{
   1.233 +	User::LeaveIfError(aStore.UpdateLinkedTypeface(*this));
   1.234 +	}
   1.235 +
   1.236 +CLinkedTypefaceSpecificationBody::CLinkedTypefaceSpecificationBody()
   1.237 +	{
   1.238 +	}
   1.239 +
   1.240 +CLinkedTypefaceSpecificationBody::~CLinkedTypefaceSpecificationBody()
   1.241 +	{
   1.242 +	delete iLinkedTypefaceName;
   1.243 +	iTypefaces.ResetAndDestroy();
   1.244 +	iGroups.ResetAndDestroy();
   1.245 +	}
   1.246 +
   1.247 +EXPORT_C CLinkedTypefaceElementSpec* CLinkedTypefaceElementSpec::NewLC(const TDesC& aElementName, TInt aGroupId)
   1.248 +	{
   1.249 +	CLinkedTypefaceElementSpec* self = new(ELeave)CLinkedTypefaceElementSpec(aGroupId);
   1.250 +	CleanupStack::PushL(self);
   1.251 +	self->ConstructL(aElementName);
   1.252 +	return self;
   1.253 +	}
   1.254 +
   1.255 +EXPORT_C CLinkedTypefaceElementSpec::~CLinkedTypefaceElementSpec()
   1.256 +	{
   1.257 +	delete iElementName;
   1.258 +	}
   1.259 +
   1.260 +EXPORT_C TPtrC CLinkedTypefaceElementSpec::ElementName() const
   1.261 +	{
   1.262 +	return *iElementName;
   1.263 +	}
   1.264 +
   1.265 +EXPORT_C void CLinkedTypefaceElementSpec::SetCanonical(TBool aIsCanonical)
   1.266 +	{
   1.267 +	iIsCanonical = aIsCanonical;
   1.268 +	}
   1.269 +
   1.270 +EXPORT_C TBool CLinkedTypefaceElementSpec::Canonical() const
   1.271 +	{
   1.272 +	return iIsCanonical;
   1.273 +	}
   1.274 +
   1.275 +CLinkedTypefaceElementSpec::CLinkedTypefaceElementSpec(TInt aGroupId)
   1.276 +	{
   1.277 +	iGroupId = aGroupId;
   1.278 +	iIsCanonical = EFalse;
   1.279 +	}
   1.280 +
   1.281 +EXPORT_C TInt CLinkedTypefaceElementSpec::GroupId() const
   1.282 +	{
   1.283 +	return iGroupId;
   1.284 +	}
   1.285 +
   1.286 +EXPORT_C COpenFontLinkedTypefaceSpecification* COpenFontLinkedTypefaceSpecification::NewLC(const TDesC& aTypefaceName)
   1.287 +	{
   1.288 +	COpenFontLinkedTypefaceSpecification* self = new (ELeave) COpenFontLinkedTypefaceSpecification();
   1.289 +	CleanupStack::PushL(self);
   1.290 +	self->ConstructL(aTypefaceName);
   1.291 +	return self;
   1.292 +	}
   1.293 +
   1.294 +EXPORT_C COpenFontLinkedTypefaceSpecification* COpenFontLinkedTypefaceSpecification::NewLC(const TLinkedTypefaceSpecificationArgs& aSpecArgs)
   1.295 +	{
   1.296 +	COpenFontLinkedTypefaceSpecification* self = new (ELeave) COpenFontLinkedTypefaceSpecification();
   1.297 +	CleanupStack::PushL(self);
   1.298 +	self->ConstructL(aSpecArgs);
   1.299 +	return self;
   1.300 +	}
   1.301 +
   1.302 +COpenFontLinkedTypefaceSpecification::COpenFontLinkedTypefaceSpecification()
   1.303 +	{
   1.304 +	}
   1.305 +
   1.306 +void COpenFontLinkedTypefaceSpecification::ConstructL(const TDesC &aTypefaceName)
   1.307 +	{
   1.308 +	TInt length = aTypefaceName.Length();
   1.309 +	if ((length > KMaxTypefaceNameLength) || (length == 0))
   1.310 +		User::Leave(KErrArgument);
   1.311 +
   1.312 +	iLinkedTypefaceName = aTypefaceName.AllocL();
   1.313 +	}
   1.314 +
   1.315 +void COpenFontLinkedTypefaceSpecification::ConstructL(const TLinkedTypefaceSpecificationArgs& aSpecArgs)
   1.316 +	{
   1.317 +	iLinkedTypefaceName = aSpecArgs.iName.AllocL();
   1.318 +
   1.319 +	TInt i;
   1.320 +	
   1.321 +	for (i = 0; i != aSpecArgs.iGroupSize ; i++)
   1.322 +		{
   1.323 +		CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(aSpecArgs.iGroups[i].iGroupId);
   1.324 +		grp->SetBaselineShift(aSpecArgs.iGroups[i].iBaselineShift);
   1.325 +		grp->SetBoldnessPercentage(aSpecArgs.iGroups[i].iBoldnessPercentage);
   1.326 +		grp->SetItalicAngle(aSpecArgs.iGroups[i].iItalicAngle);
   1.327 +		grp->SetScalingOption(aSpecArgs.iGroups[i].iScalingOption);
   1.328 +		AddLinkedTypefaceGroupL(*grp);
   1.329 +		CleanupStack::Pop(grp);
   1.330 +		}
   1.331 +	
   1.332 +	for (i = 0 ; i != aSpecArgs.iSize ; i++)
   1.333 +		{
   1.334 +		COpenFontLinkedTypefaceElementSpec* es = COpenFontLinkedTypefaceElementSpec::NewLC(aSpecArgs.iTypefaces[i].iName, aSpecArgs.iTypefaces[i].iGroupId);
   1.335 +		es->SetCanonical(aSpecArgs.iTypefaces[i].iIsCanonical);
   1.336 +		AddTypefaceAtBackL(*es);
   1.337 +		CleanupStack::Pop(es);
   1.338 +		}
   1.339 +	
   1.340 +	//ASSERT Can. Indexs match.
   1.341 +	}
   1.342 +
   1.343 +EXPORT_C COpenFontLinkedTypefaceSpecification::~COpenFontLinkedTypefaceSpecification()
   1.344 +	{
   1.345 +	delete iLinkedTypefaceName;
   1.346 +	iTypefaces.ResetAndDestroy();
   1.347 +	iTypefaces.Close();
   1.348 +	iGroups.ResetAndDestroy();
   1.349 +	iGroups.Close();
   1.350 +	}
   1.351 +
   1.352 +EXPORT_C void COpenFontLinkedTypefaceSpecification::AddTypefaceAtIndexL(COpenFontLinkedTypefaceElementSpec& aElementSpec, TInt aIndex)
   1.353 +	{
   1.354 +	DoAddTypefaceL(aElementSpec, aIndex);
   1.355 +	}
   1.356 +
   1.357 +EXPORT_C void COpenFontLinkedTypefaceSpecification::AddTypefaceAtBackL(COpenFontLinkedTypefaceElementSpec& aElementSpec)
   1.358 +	{
   1.359 +	DoAddTypefaceL(aElementSpec, iTypefaces.Count());
   1.360 +	}
   1.361 +
   1.362 +EXPORT_C TInt COpenFontLinkedTypefaceSpecification::RemoveTypeface(TInt aIndex)
   1.363 +	{
   1.364 +	if  ( (aIndex < iTypefaces.Count()) && (aIndex >= 0) )
   1.365 +		{
   1.366 +		COpenFontLinkedTypefaceElementSpec* elementSpec = iTypefaces[aIndex];
   1.367 +		iTypefaces.Remove(aIndex);
   1.368 +
   1.369 +		delete elementSpec;
   1.370 +		return KErrNone;
   1.371 +		}
   1.372 +	else
   1.373 +		return KErrNotFound;
   1.374 +	}
   1.375 +
   1.376 +EXPORT_C TInt COpenFontLinkedTypefaceSpecification::TypefaceCount() const
   1.377 +	{
   1.378 +	return iTypefaces.Count();
   1.379 +	}
   1.380 +
   1.381 +EXPORT_C TPtrC COpenFontLinkedTypefaceSpecification::Name() const
   1.382 +	{
   1.383 +	return *iLinkedTypefaceName;
   1.384 +	}
   1.385 +
   1.386 +EXPORT_C TInt COpenFontLinkedTypefaceSpecification::CanonicalIndex() const
   1.387 +	{
   1.388 +	TInt index = KErrNotFound;
   1.389 +	for (TInt i = iTypefaces.Count()-1 ; i >= 0; i--)
   1.390 +		{
   1.391 +		if (iTypefaces[i]->Canonical())
   1.392 +			{
   1.393 +			if (index == KErrNotFound)
   1.394 +				index = i;
   1.395 +			else 
   1.396 +				return KErrOverflow;
   1.397 +			}
   1.398 +		}
   1.399 +	return index;
   1.400 +	}
   1.401 +
   1.402 +EXPORT_C COpenFontLinkedTypefaceElementSpec* COpenFontLinkedTypefaceSpecification::Typeface(TInt aIndex) const
   1.403 +	{
   1.404 +	if ((aIndex >= iTypefaces.Count()) || (aIndex < 0))
   1.405 +		{
   1.406 +		return NULL;
   1.407 +		}
   1.408 +	else
   1.409 +		{
   1.410 +		return iTypefaces[aIndex];
   1.411 +		}
   1.412 +	}
   1.413 +
   1.414 +void COpenFontLinkedTypefaceSpecification::DoAddTypefaceL(COpenFontLinkedTypefaceElementSpec& aElementSpec, TInt aPos)
   1.415 +	{
   1.416 +	if (iTypefaces.Count() == KMaxLinkedTypefaces)
   1.417 +		User::Leave(KErrOverflow);
   1.418 +	
   1.419 +	TInt err = iTypefaces.Find(&aElementSpec);
   1.420 +
   1.421 +	if (err != KErrNotFound)
   1.422 +		User::Leave(KErrAlreadyExists);
   1.423 +	
   1.424 +	if (aElementSpec.Canonical() && CanonicalIndex() >= 0)
   1.425 +		User::Leave(KErrArgument);
   1.426 +	
   1.427 +	if (GroupById(aElementSpec.GroupId()) == NULL)
   1.428 +		User::Leave(KErrArgument);
   1.429 +	
   1.430 +	err = iTypefaces.Insert(&aElementSpec, aPos);
   1.431 +
   1.432 +	User::LeaveIfError(err);
   1.433 +	}
   1.434 +
   1.435 +EXPORT_C void COpenFontLinkedTypefaceSpecification::AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup)
   1.436 +	{
   1.437 +	if (iGroups.Count() == KMaxLinkedTypefaceGroups)
   1.438 +		User::Leave(KErrOverflow);
   1.439 +	
   1.440 +	for (TInt i = iGroups.Count()-1 ; i >= 0 ; i--)
   1.441 +		{
   1.442 +		if (iGroups[i]->GroupId() == aGroup.GroupId())
   1.443 +			User::Leave(KErrAlreadyExists);
   1.444 +		}
   1.445 +	iGroups.AppendL(&aGroup);
   1.446 +	}
   1.447 +
   1.448 +EXPORT_C TInt COpenFontLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup(TInt aGroupId)
   1.449 +	{
   1.450 +	//Search for & remove the group if it exists
   1.451 +	CLinkedTypefaceGroup* remove = GroupById(aGroupId);
   1.452 +	//If the group has been found & removed remove all associated typefaces
   1.453 +	if (remove)
   1.454 +		{
   1.455 +		COpenFontLinkedTypefaceElementSpec* elementSpec;
   1.456 +		for (TInt i = iTypefaces.Count()-1 ; i >= 0 ; i--)
   1.457 +			{
   1.458 +			elementSpec = iTypefaces[i];
   1.459 +			if (elementSpec->GroupId() == aGroupId)
   1.460 +				RemoveTypeface(i);
   1.461 +			}
   1.462 +		iGroups.Remove(iGroups.Find(remove));
   1.463 +		delete remove;
   1.464 +		return KErrNone;
   1.465 +		}
   1.466 +	return KErrNotFound;
   1.467 +	}
   1.468 +
   1.469 +EXPORT_C CLinkedTypefaceGroup* COpenFontLinkedTypefaceSpecification::GroupById(TInt aGroupId) const
   1.470 +	{
   1.471 +	TInt index;
   1.472 +	TBool found = EFalse;
   1.473 +	for (index = iGroups.Count()-1; index != -1 ; index--)
   1.474 +		{
   1.475 +		if (iGroups[index]->GroupId() == aGroupId)
   1.476 +			{
   1.477 +			found = ETrue;
   1.478 +			break;
   1.479 +			}
   1.480 +		}
   1.481 +	
   1.482 +	if (found)
   1.483 +		return iGroups[index];
   1.484 +	else
   1.485 +		return NULL;
   1.486 +	}
   1.487 +
   1.488 +EXPORT_C const CLinkedTypefaceGroup* COpenFontLinkedTypefaceSpecification::Group(TInt aGroupIndex) const
   1.489 +	{
   1.490 +	if ( (aGroupIndex >= 0) && (aGroupIndex < iGroups.Count()) )
   1.491 +		return iGroups[aGroupIndex];
   1.492 +	else
   1.493 +		return NULL;
   1.494 +	}
   1.495 +
   1.496 +EXPORT_C TInt COpenFontLinkedTypefaceSpecification::GroupCount() const
   1.497 +	{
   1.498 +	return iGroups.Count();
   1.499 +	}
   1.500 +
   1.501 +COpenFontLinkedTypefaceSpecificationBody::COpenFontLinkedTypefaceSpecificationBody()
   1.502 +	{
   1.503 +	}
   1.504 +
   1.505 +// destructor
   1.506 +COpenFontLinkedTypefaceSpecificationBody::~COpenFontLinkedTypefaceSpecificationBody()
   1.507 +	{
   1.508 +	delete iLinkedTypefaceName;
   1.509 +	iTypefaces.Reset();
   1.510 +	}
   1.511 +
   1.512 +EXPORT_C COpenFontLinkedTypefaceElementSpec* COpenFontLinkedTypefaceElementSpec::NewLC(const TDesC& aElementName, TInt aGroupId)
   1.513 +	{
   1.514 +	COpenFontLinkedTypefaceElementSpec* self = new(ELeave)COpenFontLinkedTypefaceElementSpec(aGroupId);
   1.515 +	CleanupStack::PushL(self);
   1.516 +	self->ConstructL(aElementName);
   1.517 +	return self;
   1.518 +	}
   1.519 +
   1.520 +EXPORT_C COpenFontLinkedTypefaceElementSpec::~COpenFontLinkedTypefaceElementSpec()
   1.521 +	{
   1.522 +	delete iElementName;
   1.523 +	delete iFileName;
   1.524 +	}
   1.525 +
   1.526 +EXPORT_C TPtrC COpenFontLinkedTypefaceElementSpec::ElementName() const
   1.527 +	{
   1.528 +	return *iElementName;
   1.529 +	}
   1.530 +
   1.531 +EXPORT_C void COpenFontLinkedTypefaceElementSpec::SetCanonical(TBool aIsCanonical)
   1.532 +	{
   1.533 +	iIsCanonical = aIsCanonical;
   1.534 +	}
   1.535 +
   1.536 +EXPORT_C TBool COpenFontLinkedTypefaceElementSpec::Canonical() const
   1.537 +	{
   1.538 +	return iIsCanonical;
   1.539 +	}
   1.540 +
   1.541 +EXPORT_C TInt COpenFontLinkedTypefaceElementSpec::GroupId() const
   1.542 +	{
   1.543 +	return iGroupId;
   1.544 +	}
   1.545 +
   1.546 +EXPORT_C TPtrC COpenFontLinkedTypefaceElementSpec::FileName() const
   1.547 +	{
   1.548 +	return *iFileName;
   1.549 +	}
   1.550 +
   1.551 +EXPORT_C void COpenFontLinkedTypefaceElementSpec::SetFileNameL(const TDesC& aFileName)
   1.552 +	{
   1.553 +	iFileName = aFileName.AllocL();
   1.554 +	}
   1.555 +
   1.556 +COpenFontLinkedTypefaceElementSpec::COpenFontLinkedTypefaceElementSpec(TInt aGroupId)
   1.557 +	{
   1.558 +	iGroupId = aGroupId;
   1.559 +	}
   1.560 +
   1.561 +void COpenFontLinkedTypefaceElementSpec::ConstructL(const TDesC& aName)
   1.562 +	{
   1.563 +	TInt length = aName.Length();
   1.564 +	if ((length == 0) || (length > KMaxTypefaceNameLength))
   1.565 +		User::Leave(KErrArgument);
   1.566 +	iElementName = aName.AllocL();
   1.567 +	}
   1.568 +
   1.569 +void CLinkedTypefaceElementSpec::ConstructL(const TDesC& aName)
   1.570 +	{
   1.571 +	TInt length = aName.Length();
   1.572 +	if ((length == 0) || (length > KMaxTypefaceNameLength))
   1.573 +		User::Leave(KErrArgument);
   1.574 +	iElementName = aName.AllocL();
   1.575 +	}
   1.576 +
   1.577 +EXPORT_C CLinkedTypefaceGroup* CLinkedTypefaceGroup::NewLC(TInt aGroupId)
   1.578 +	{
   1.579 +	CLinkedTypefaceGroup* self = new (ELeave) CLinkedTypefaceGroup(aGroupId);
   1.580 +	CleanupStack::PushL(self);
   1.581 +	return self;
   1.582 +	}
   1.583 +
   1.584 +CLinkedTypefaceGroup::CLinkedTypefaceGroup(TInt aGroupId)
   1.585 +	{
   1.586 +	iGroupId = aGroupId;
   1.587 +	iScalingOption = EScalingNone;
   1.588 +	iBaselineShift = ENoBaselineShift;
   1.589 +	iBoldnessPercentage = -1;
   1.590 +	iItalicAngle = -1;
   1.591 +	}
   1.592 +
   1.593 +CLinkedTypefaceGroup::~CLinkedTypefaceGroup()
   1.594 +	{
   1.595 +	}
   1.596 +
   1.597 +EXPORT_C void CLinkedTypefaceGroup::SetScalingOption(CLinkedTypefaceGroup::TScalingOption aOption)
   1.598 +	{
   1.599 +	iScalingOption = aOption;
   1.600 +	}
   1.601 +
   1.602 +EXPORT_C CLinkedTypefaceGroup::TScalingOption CLinkedTypefaceGroup::ScalingOption() const
   1.603 +	{
   1.604 +	return iScalingOption;
   1.605 +	}
   1.606 +
   1.607 +EXPORT_C void CLinkedTypefaceGroup::SetBaselineShift(CLinkedTypefaceGroup::TBaselineShift aShift)
   1.608 +	{
   1.609 +	iBaselineShift = aShift;
   1.610 +	}
   1.611 +
   1.612 +EXPORT_C CLinkedTypefaceGroup::TBaselineShift CLinkedTypefaceGroup::BaselineShift() const
   1.613 +	{
   1.614 +	return iBaselineShift;
   1.615 +	}
   1.616 +
   1.617 +EXPORT_C void CLinkedTypefaceGroup::SetBoldnessPercentage(TInt aPercentage)
   1.618 +	{
   1.619 +	iBoldnessPercentage = aPercentage;
   1.620 +	}
   1.621 +
   1.622 +EXPORT_C TInt CLinkedTypefaceGroup::BoldnessPercentage() const
   1.623 +	{
   1.624 +	return iBoldnessPercentage;
   1.625 +	}
   1.626 +
   1.627 +EXPORT_C TInt CLinkedTypefaceGroup::GroupId() const
   1.628 +	{
   1.629 +	return iGroupId;
   1.630 +	}
   1.631 +
   1.632 +EXPORT_C TInt CLinkedTypefaceGroup::ItalicAngle() const
   1.633 +	{
   1.634 +	return iItalicAngle;
   1.635 +	}
   1.636 +
   1.637 +EXPORT_C void CLinkedTypefaceGroup::SetItalicAngle(TInt aAngle)
   1.638 +	{
   1.639 +	iItalicAngle = aAngle;
   1.640 +	}
   1.641 +
   1.642 +EXPORT_C void TLinkedTypefaceSpecificationArgs::operator =(const CLinkedTypefaceSpecification& aRhs)
   1.643 +	{
   1.644 +	iSize = aRhs.TypefaceCount();
   1.645 +	iGroupSize = aRhs.GroupCount();
   1.646 +	iName = aRhs.Name();
   1.647 +	
   1.648 +	TInt i;
   1.649 +	for (i = 0 ; i != iSize ; i++)
   1.650 +		iTypefaces[i] = aRhs.Typeface(i);
   1.651 +	
   1.652 +	for (i = 0 ; i != iGroupSize ; i++)
   1.653 +		iGroups[i] = aRhs.Group(i);
   1.654 +	}
   1.655 +
   1.656 +EXPORT_C void TLinkedTypefaceSpecificationArgs::operator =(const COpenFontLinkedTypefaceSpecification &aRhs)
   1.657 +	{
   1.658 +	iSize = aRhs.TypefaceCount();
   1.659 +	iGroupSize = aRhs.GroupCount();
   1.660 +	iName = aRhs.Name();
   1.661 +	
   1.662 +	TInt i;
   1.663 +	for (i = 0 ; i != iSize ; i++)
   1.664 +		iTypefaces[i] = aRhs.Typeface(i);
   1.665 +	
   1.666 +	for (i = 0 ; i != iGroupSize ; i++)
   1.667 +		iGroups[i] = aRhs.Group(i);
   1.668 +	}
   1.669 +
   1.670 +void TLinkedTypefaceElementSpecArgs::operator = (const CLinkedTypefaceElementSpec* aRhs)
   1.671 +	{
   1.672 +	iIsCanonical = aRhs->Canonical();
   1.673 +	iGroupId = aRhs->GroupId();
   1.674 +	iName = aRhs->ElementName();
   1.675 +	}
   1.676 +
   1.677 +void TLinkedTypefaceElementSpecArgs::operator = (const COpenFontLinkedTypefaceElementSpec* aRhs)
   1.678 +	{
   1.679 +	iIsCanonical = aRhs->Canonical();
   1.680 +	iGroupId = aRhs->GroupId();
   1.681 +	iName = aRhs->ElementName();
   1.682 +	}
   1.683 +
   1.684 +void TLinkedTypefaceGroupArgs::operator =(const CLinkedTypefaceGroup* aRhs)
   1.685 +	{
   1.686 +	iGroupId = aRhs->GroupId();
   1.687 +	iScalingOption = aRhs->ScalingOption();
   1.688 +	iBaselineShift = aRhs->BaselineShift();
   1.689 +	iBoldnessPercentage = aRhs->BoldnessPercentage();
   1.690 +	iItalicAngle = aRhs->ItalicAngle();
   1.691 +	}