graphics/fbserv/src/T_DataFbsTypefaceStore.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 /*
       
     2 * Copyright (c) 2005-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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @test
       
    20 @internalComponent
       
    21 
       
    22 This contains CT_DataFbsTypefaceStore
       
    23 */
       
    24 
       
    25 #include "T_DataFbsTypefaceStore.h"
       
    26 #include "T_GraphicsUtil.h"
       
    27 
       
    28 
       
    29 /*@{*/
       
    30 ///	Parameters
       
    31 _LIT(KAllFonts,										"all_fonts");
       
    32 _LIT(KDriveName,									"drive_name");
       
    33 _LIT(KFileName,										"file_name");
       
    34 _LIT(KFont,											"font");
       
    35 _LIT(KFontUid,										"font_uid");
       
    36 _LIT(KFontNameAlias,								"font_name_alias");
       
    37 _LIT(KFontName,										"font_name");
       
    38 _LIT(KLanguage,										"language");
       
    39 _LIT(KTypefaceId,									"typeface_id");
       
    40 _LIT(KGraphicsDevice,								"graphics_device");
       
    41 _LIT(KFontMaxHeight,								"font_max_height");
       
    42 _LIT(KTypefaceIndex,								"typeface_index");
       
    43 _LIT(KHeightIndex,									"height_index");
       
    44 _LIT(KUseFileName,									"use_file_name");
       
    45 _LIT(KUseDriveName,									"use_drive_name");
       
    46 _LIT(KAlgStyle,										"alg_style");
       
    47 _LIT(KCheckAgainstMaximum,							"check_against_maximum");
       
    48 _LIT(KCheckHeightPositive,							"check_height_positive");
       
    49 _LIT(KGlyphBitmapType,								"glyph_bitmap_type");
       
    50 
       
    51 ///	Commands
       
    52 _LIT(KCmdNewL,										"NewL");
       
    53 _LIT(KCmdAddFile,									"AddFile");
       
    54 _LIT(KCmdInstallFile,								"InstallFile");
       
    55 _LIT(KCmdRemoveFile,			 					"RemoveFile");
       
    56 _LIT(KCmdGetNearestFontInPixels,					"GetNearestFontInPixels");
       
    57 _LIT(KCmdGetNearestFontToDesignHeightInPixels,		"GetNearestFontToDesignHeightInPixels");
       
    58 _LIT(KCmdGetNearestFontToMaxHeightInPixels,			"GetNearestFontToMaxHeightInPixels");
       
    59 _LIT(KCmdGetFontById, 			 					"GetFontById");
       
    60 _LIT(KCmdFontHeightInPixels,						"FontHeightInPixels");
       
    61 _LIT(KCmdDefaultBitmapType, 						"DefaultBitmapType");
       
    62 _LIT(KCmdSetDefaultBitmapType, 						"SetDefaultBitmapType");
       
    63 _LIT(KCmdSetFontNameAliasL,							"SetFontNameAliasL");
       
    64 _LIT(KCmdSetDefaultLanguageForMetrics,				"SetDefaultLanguageForMetrics");
       
    65 _LIT(KCmdRemoveFontFileLocksL,						"RemoveFontFileLocksL");
       
    66 _LIT(KCmdSetSystemDefaultTypefaceName,				"SetSystemDefaultTypefaceNameL");
       
    67 _LIT(KCmdDestructor,								"~");
       
    68 
       
    69 ///	Logging
       
    70 _LIT(KLogError,										"Error=%d");
       
    71 _LIT(KLogMissingParameter,							"Missing parameter '%S'");
       
    72 /*@}*/
       
    73 
       
    74 
       
    75 /**
       
    76 * Two phase constructor
       
    77 */
       
    78 CT_DataFbsTypefaceStore* CT_DataFbsTypefaceStore::NewL()
       
    79 	{
       
    80 	CT_DataFbsTypefaceStore* ret = new (ELeave) CT_DataFbsTypefaceStore();
       
    81 	CleanupStack::PushL(ret);
       
    82 	ret->ConstructL();
       
    83 	CleanupStack::Pop(ret);
       
    84 	return ret;
       
    85 	}
       
    86 
       
    87 
       
    88 /**
       
    89 * Protected constructor. First phase construction
       
    90 */
       
    91 CT_DataFbsTypefaceStore::CT_DataFbsTypefaceStore()
       
    92 :	CT_DataTypefaceStore()
       
    93 ,	iFbsTypefaceStore(NULL)
       
    94 ,	iLastTypefaceFileId(0)
       
    95 	{
       
    96 	}
       
    97 
       
    98 
       
    99 /**
       
   100 * Protected second phase construction
       
   101 */
       
   102 void CT_DataFbsTypefaceStore::ConstructL()
       
   103 	{
       
   104 	}
       
   105 
       
   106 
       
   107 /**
       
   108 * Destructor.
       
   109 */
       
   110 CT_DataFbsTypefaceStore::~CT_DataFbsTypefaceStore()
       
   111 	{
       
   112 	DestroyData();
       
   113 	}
       
   114 
       
   115 
       
   116 /**
       
   117 * cleanup implementation.
       
   118 */
       
   119 void CT_DataFbsTypefaceStore::DestroyData()
       
   120 	{
       
   121 	delete iFbsTypefaceStore;
       
   122 	iFbsTypefaceStore = NULL;
       
   123 	}
       
   124 
       
   125 
       
   126 /**
       
   127 * Return a pointer to the object that the data wraps
       
   128 *
       
   129 * @return pointer to the object that the data wraps
       
   130 */
       
   131 TAny* CT_DataFbsTypefaceStore::GetObject()
       
   132 	{
       
   133 	return iFbsTypefaceStore;
       
   134 	}
       
   135 
       
   136 
       
   137 /**
       
   138 * Process a command read from the ini file
       
   139 *
       
   140 * @param aDataWrapper	test step requiring command to be processed
       
   141 * @param aCommand	the command to process
       
   142 * @param aSection		the entry in the ini file requiring the command to be processed
       
   143 *
       
   144 * @return ETrue if the command is processed
       
   145 */
       
   146 TBool CT_DataFbsTypefaceStore::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   147 	{
       
   148 	TBool	ret=ETrue;
       
   149 
       
   150 	if (aCommand == KCmdNewL)
       
   151 		{
       
   152 		DoCmdNewL(aSection);
       
   153 		}
       
   154 	else if (aCommand == KCmdAddFile)
       
   155 		{
       
   156 		DoCmdAddFile(aSection);
       
   157 		}
       
   158 	else if (aCommand == KCmdInstallFile)
       
   159 		{
       
   160 		DoCmdInstallFile(aSection);
       
   161 		}
       
   162 	else if (aCommand == KCmdRemoveFile)
       
   163 		{
       
   164 		DoCmdRemoveFile(aSection);
       
   165 		}
       
   166 	else if (aCommand == KCmdGetNearestFontInPixels)
       
   167 		{
       
   168 		DoCmdGetNearestFontInPixelsL(aSection);
       
   169 		}
       
   170 	else if (aCommand == KCmdGetNearestFontToDesignHeightInPixels)
       
   171 		{
       
   172 		DoCmdGetNearestFontToDesignHeightInPixelsL(aSection);
       
   173 		}
       
   174 	else if (aCommand == KCmdGetNearestFontToMaxHeightInPixels)
       
   175 		{
       
   176 		DoCmdGetNearestFontToMaxHeightInPixelsL(aSection);
       
   177 		}
       
   178 	else if (aCommand == KCmdGetFontById)
       
   179 		{
       
   180 		DoCmdGetFontByIdL(aSection);
       
   181 		}
       
   182 	else if (aCommand == KCmdFontHeightInPixels)
       
   183 		{
       
   184 		DoCmdFontHeightInPixels(aSection);
       
   185 		}
       
   186 	else if (aCommand == KCmdDefaultBitmapType)
       
   187 		{
       
   188 		DoCmdDefaultBitmapType(aSection);
       
   189 		}
       
   190 	else if (aCommand == KCmdSetDefaultBitmapType)
       
   191 		{
       
   192 		DoCmdSetDefaultBitmapType(aSection);
       
   193 		}
       
   194 	else if (aCommand == KCmdSetFontNameAliasL)
       
   195 		{
       
   196 		DoCmdSetFontNameAlias(aSection);
       
   197 		}
       
   198 	else if (aCommand == KCmdSetDefaultLanguageForMetrics)
       
   199 		{
       
   200 		DoCmdSetDefaultLanguageForMetrics(aSection);
       
   201 		}
       
   202 	else if (aCommand == KCmdRemoveFontFileLocksL)
       
   203 		{
       
   204 		DoCmdRemoveFontFileLocks(aSection);
       
   205 		}
       
   206 	else if (aCommand == KCmdSetSystemDefaultTypefaceName)
       
   207 		{
       
   208 		DoCmdSetSystemDefaultTypefaceName(aSection);
       
   209 		}
       
   210 	else if (aCommand == KCmdDestructor)
       
   211 		{
       
   212 		DestroyData();
       
   213 		}
       
   214 	else
       
   215 		{
       
   216 		ret=CT_DataTypefaceStore::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   217 		}
       
   218 
       
   219 	return ret;
       
   220 	}
       
   221 
       
   222 
       
   223 CTypefaceStore* CT_DataFbsTypefaceStore::GetTypefaceStore() const
       
   224 	{
       
   225 	return iFbsTypefaceStore;
       
   226 	}
       
   227 
       
   228 
       
   229 
       
   230 ////////////////// COMMANDS IMPLEMENTATION  ////////////////////////
       
   231 
       
   232 /** CFbsTypefaceStore::NewL() call */
       
   233 void CT_DataFbsTypefaceStore::DoCmdNewL(const TDesC& aSection)
       
   234 	{
       
   235 	INFO_PRINTF1(_L("CFbsTypefaceStore::NewL() call"));
       
   236 
       
   237 	// cleanup if any
       
   238 	DestroyData();
       
   239 
       
   240 
       
   241 	// get FbsBitmapData object from parameters
       
   242 	CGraphicsDevice*	device=NULL;
       
   243 	TPtrC	deviceName;
       
   244 	if ( GetStringFromConfig(aSection, KGraphicsDevice(), deviceName) )
       
   245 		{
       
   246 		// check that the data object was found
       
   247 		device=static_cast<CGraphicsDevice*>(GetDataObjectL(deviceName));
       
   248 		}
       
   249 
       
   250 	// do create
       
   251 	TRAPD(err, iFbsTypefaceStore = CFbsTypefaceStore::NewL(device));
       
   252 
       
   253 	// check error code
       
   254 	if (err != KErrNone)
       
   255 		{
       
   256 		ERR_PRINTF2(_L("CFbsTypefaceStore creation error: %d"), err);
       
   257 		SetError(err);
       
   258 		}
       
   259 	}
       
   260 
       
   261 
       
   262 /** Call CFbsTypefaceStore::GetNearestFontInPixels() */
       
   263 void CT_DataFbsTypefaceStore::DoCmdGetNearestFontInPixelsL(const TDesC& aSection)
       
   264 	{
       
   265 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::GetNearestFontInPixels()"));
       
   266 
       
   267 	TFontSpec	fontSpec;
       
   268 	if ( !GetFontSpecFromConfig(aSection, KFont, fontSpec) )
       
   269 		{
       
   270 		ERR_PRINTF2(KLogMissingParameter, &KFont());
       
   271 		SetBlockResult(EFail);
       
   272 		}
       
   273 	else
       
   274 		{
       
   275 		// call CFbsTypefaceStore::GetNearestFontInPixels()
       
   276 		CFont*		font = NULL;
       
   277 		TInt		err = iFbsTypefaceStore->GetNearestFontInPixels(font, fontSpec);
       
   278 
       
   279 		// check error code
       
   280 		if (err != KErrNone)
       
   281 			{
       
   282 			ERR_PRINTF2(KLogError, err);
       
   283 			SetError(err);
       
   284 			}
       
   285 		else
       
   286 			{
       
   287 			// set fbs font data object of provided
       
   288 			SetFontDataObjectIfPassedAsParameterL(font, aSection);
       
   289 			}
       
   290 		}
       
   291 	}
       
   292 
       
   293 
       
   294 /** Call CFbsTypefaceStore::GetNearestFontToDesignHeightInPixels() */
       
   295 void CT_DataFbsTypefaceStore::DoCmdGetNearestFontToDesignHeightInPixelsL(const TDesC& aSection)
       
   296 	{
       
   297 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::GetNearestFontToDesignHeightInPixels()"));
       
   298 
       
   299 	TFontSpec	fontSpec;
       
   300 	if ( !GetFontSpecFromConfig(aSection, KFont, fontSpec) )
       
   301 		{
       
   302 		ERR_PRINTF2(KLogMissingParameter, &KFont());
       
   303 		SetBlockResult(EFail);
       
   304 		}
       
   305 	else
       
   306 		{
       
   307 		// call CFbsTypefaceStore::GetNearestFontToDesignHeightInPixels()
       
   308 		CFont*		fbsFont = NULL;
       
   309 		TInt		err = iFbsTypefaceStore->GetNearestFontToDesignHeightInPixels(fbsFont, fontSpec);
       
   310 
       
   311 		// check error code
       
   312 		if (err != KErrNone)
       
   313 			{
       
   314 			ERR_PRINTF2(KLogError, err);
       
   315 			SetError(err);
       
   316 			}
       
   317 		else
       
   318 			{
       
   319 			// set fbs font data object of provided
       
   320 			SetFontDataObjectIfPassedAsParameterL(fbsFont, aSection);
       
   321 			}
       
   322 		}
       
   323 	}
       
   324 
       
   325 
       
   326 /** Call CFbsTypefaceStore::GetNearestFontToMaxHeightInPixels() */
       
   327 void CT_DataFbsTypefaceStore::DoCmdGetNearestFontToMaxHeightInPixelsL(const TDesC& aSection)
       
   328 	{
       
   329 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::GetNearestFontToMaxHeightInPixels()"));
       
   330 
       
   331 	TBool		dataOk=ETrue;
       
   332 
       
   333 	TFontSpec	fontSpec;
       
   334 	if ( !GetFontSpecFromConfig(aSection, KFont, fontSpec) )
       
   335 		{
       
   336 		dataOk=EFalse;
       
   337 		ERR_PRINTF2(KLogMissingParameter, &KFont());
       
   338 		SetBlockResult(EFail);
       
   339 		}
       
   340 
       
   341 	TInt	fontMaxHeight;
       
   342 	if ( !GetIntFromConfig(aSection, KFontMaxHeight(), fontMaxHeight) )
       
   343 		{
       
   344 		dataOk=EFalse;
       
   345 		ERR_PRINTF2(KLogMissingParameter, &KFontMaxHeight());
       
   346 		SetBlockResult(EFail);
       
   347 		}
       
   348 
       
   349 	if ( dataOk )
       
   350 		{
       
   351 		// call CFbsTypefaceStore::GetNearestFontToMaxHeightInPixels()
       
   352 		CFont*		fbsFont = NULL;
       
   353 		TInt		err = iFbsTypefaceStore->GetNearestFontToMaxHeightInPixels(fbsFont, fontSpec, fontMaxHeight);
       
   354 
       
   355 		// check error code
       
   356 		if (err != KErrNone)
       
   357 			{
       
   358 			ERR_PRINTF2(_L("Get nearest font to max height in twips error: %d"), err);
       
   359 			SetError(err);
       
   360 			}
       
   361 		else
       
   362 			{
       
   363 			// set fbs font data object of provided
       
   364 			SetFontDataObjectIfPassedAsParameterL(fbsFont, aSection);
       
   365 
       
   366 			// get check against maximum parameter from parameters
       
   367 			TBool	checkAgainstMaximum = EFalse;
       
   368 			GetBoolFromConfig(aSection, KCheckAgainstMaximum(), checkAgainstMaximum);
       
   369 
       
   370 			if ( checkAgainstMaximum )
       
   371 				{
       
   372 				// check that the height of the returned font is not greater that the maximum specified
       
   373 				if (fbsFont->HeightInPixels() > fontMaxHeight)
       
   374 					{
       
   375 					ERR_PRINTF3(_L("Font doesn't match in maximum specified, height: %d, maximum: %d"), fbsFont->HeightInPixels(), fontMaxHeight);
       
   376 					SetBlockResult(EFail);
       
   377 					}
       
   378 				}
       
   379 			}
       
   380 		}
       
   381 	}
       
   382 
       
   383 
       
   384 /** Call CFbsTypefaceStore::AddFile(), remeber typeface id */
       
   385 void CT_DataFbsTypefaceStore::DoCmdAddFile(const TDesC& aSection)
       
   386 	{
       
   387 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::AddFile(), remeber typeface id"));
       
   388 
       
   389 	// get font file name from parameters
       
   390 	TPtrC	fileName;
       
   391 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
   392 		{
       
   393 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
   394 		SetBlockResult(EFail);
       
   395 		}
       
   396 	else
       
   397 		{
       
   398 		// call AddFile()
       
   399 		TInt	err = iFbsTypefaceStore->AddFile(fileName, iLastTypefaceFileId);
       
   400 		INFO_PRINTF2(_L("Id %d"), iLastTypefaceFileId);
       
   401 
       
   402 		// check error code
       
   403 		if (err != KErrNone)
       
   404 			{
       
   405 			ERR_PRINTF2(_L("Add file error: %d"), err);
       
   406 			SetError(err);
       
   407 			}
       
   408 		}
       
   409 	}
       
   410 
       
   411 
       
   412 /** Call CFbsTypefaceStore::InstallFile(), remeber typeface id */
       
   413 void CT_DataFbsTypefaceStore::DoCmdInstallFile(const TDesC& aSection)
       
   414 	{
       
   415 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::InstallFile(), remeber typeface id"));
       
   416 
       
   417 	// get font file name from parameters
       
   418 	TPtrC	fileName;
       
   419 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
   420 		{
       
   421 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
   422 		SetBlockResult(EFail);
       
   423 		}
       
   424 	else
       
   425 		{
       
   426 		// call InstallFile()
       
   427 		TInt	err = iFbsTypefaceStore->InstallFile(fileName, iLastTypefaceFileId);
       
   428 		INFO_PRINTF2(_L("Id %d"), iLastTypefaceFileId);
       
   429 
       
   430 		// check error code
       
   431 		if (err != KErrNone)
       
   432 			{
       
   433 			ERR_PRINTF2(_L("Install file error: %d"), err);
       
   434 			SetError(err);
       
   435 			}
       
   436 		}
       
   437 	}
       
   438 
       
   439 
       
   440 /** Call CFbsTypefaceStore::RemoveFile() */
       
   441 void CT_DataFbsTypefaceStore::DoCmdRemoveFile(const TDesC& aSection)
       
   442 	{
       
   443 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::RemoveFile()"));
       
   444 
       
   445 	// get typeface id from parameters if provided
       
   446 	TInt	typefaceId=iLastTypefaceFileId;
       
   447 	GetIntFromConfig(aSection, KTypefaceId(), typefaceId);
       
   448 	INFO_PRINTF2(_L("Typeface id provided : %d"), typefaceId);
       
   449 
       
   450 	// call RemoveFile()
       
   451 	iFbsTypefaceStore->RemoveFile(typefaceId);
       
   452 	}
       
   453 
       
   454 
       
   455 /** Call CFbsTypefaceStore::GetFontById() */
       
   456 void CT_DataFbsTypefaceStore::DoCmdGetFontByIdL(const TDesC& aSection)
       
   457 	{
       
   458 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::GetFontById()"));
       
   459 
       
   460 	// get font uid from parameters
       
   461 	TInt	fontUid;
       
   462 	if(!GetIntFromConfig(aSection, KFontUid(), fontUid))
       
   463 		{
       
   464 		ERR_PRINTF2(_L("No %S"), &KFontUid());
       
   465 		SetBlockResult(EFail);
       
   466 		}
       
   467 
       
   468 	// call GetFontById()
       
   469 	TAlgStyle*	algStylePointer = NULL;
       
   470 	CT_GraphicsUtil::GetAlgStyleL(*this, aSection, KAlgStyle(), algStylePointer);
       
   471 
       
   472 	CFont* 	fbsFont = NULL;
       
   473 	TInt	err = KErrNone;
       
   474 	if (algStylePointer == NULL)
       
   475 		{
       
   476 		TAlgStyle	algStyle;
       
   477 		err = iFbsTypefaceStore->GetFontById(fbsFont, TUid::Uid(fontUid), algStyle);
       
   478 		}
       
   479 	else
       
   480 		{
       
   481 		err = iFbsTypefaceStore->GetFontById(fbsFont, TUid::Uid(fontUid), *algStylePointer);
       
   482 		}
       
   483 
       
   484 	// check error code
       
   485 	if (err != KErrNone)
       
   486 		{
       
   487 		ERR_PRINTF2(_L("Get font by id error: %d"), err);
       
   488 		SetError(err);
       
   489 		}
       
   490 	}
       
   491 
       
   492 
       
   493 /** Call CFbsTypefaceStore::FontHeightInPixels() */
       
   494 void CT_DataFbsTypefaceStore::DoCmdFontHeightInPixels(const TDesC& aSection)
       
   495 	{
       
   496 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::FontHeightInPixels()"));
       
   497 	TBool								dataOk=ETrue;
       
   498 
       
   499 	// get typeface index from parameters
       
   500 	TInt	typefaceIndex;
       
   501 	if(!GetIntFromConfig(aSection, KTypefaceIndex(), typefaceIndex))
       
   502 		{
       
   503 		ERR_PRINTF2(_L("No %S"), &KTypefaceIndex());
       
   504 		SetBlockResult(EFail);
       
   505 		dataOk=EFalse;
       
   506 		}
       
   507 
       
   508 	// get height index from parameters
       
   509 	TInt	heightIndex;
       
   510 	if(!GetIntFromConfig(aSection, KHeightIndex(), heightIndex))
       
   511 		{
       
   512 		ERR_PRINTF2(_L("No %S"), &KHeightIndex());
       
   513 		SetBlockResult(EFail);
       
   514 		dataOk=EFalse;
       
   515 		}
       
   516 
       
   517 	if ( dataOk )
       
   518 		{
       
   519 		TInt	typefaceHeight = iFbsTypefaceStore->FontHeightInPixels(typefaceIndex, heightIndex);
       
   520 
       
   521 		// get positive height check flag from parameters
       
   522 		TBool	checkHeightPositive = EFalse;
       
   523 		GetBoolFromConfig(aSection, KCheckHeightPositive(), checkHeightPositive);
       
   524 
       
   525 		// check that TTypefaceSupport fields are set
       
   526 		if ( checkHeightPositive && (typefaceHeight<=0) )
       
   527 			{
       
   528 			ERR_PRINTF2(_L("Typeface height is not greater than 0, height: %d"), typefaceHeight);
       
   529 			SetBlockResult(EFail);
       
   530 			}
       
   531 		}
       
   532 	}
       
   533 
       
   534 
       
   535 /** Call CFbsTypefaceStore::DefaultBitmapType() and compare value with expected */
       
   536 void CT_DataFbsTypefaceStore::DoCmdDefaultBitmapType(const TDesC& aSection)
       
   537 	{
       
   538 	// get actual value of default bitmap type
       
   539 	TGlyphBitmapType	actualValue = iFbsTypefaceStore->DefaultBitmapType();
       
   540 
       
   541 	INFO_PRINTF2(_L("CFbsTypefaceStore::DefaultBitmapType() %d"), actualValue);
       
   542 
       
   543 
       
   544 	// get expected value of default bitmap type from parameters
       
   545 	TGlyphBitmapType	expectedType;
       
   546 	if (!CT_GraphicsUtil::ReadGlyphBitmapType(*this, aSection, KGlyphBitmapType(), expectedType))
       
   547 		{
       
   548 		ERR_PRINTF1(_L("No glyph_bitmap_type"));
       
   549 		SetBlockResult(EFail);
       
   550 		}
       
   551 
       
   552 	// compare
       
   553 	if (actualValue != expectedType)
       
   554 		{
       
   555 		ERR_PRINTF3(_L("Value of default bitmap type is not as expected, expected: %d, actual: %d"), expectedType, actualValue);
       
   556 		SetBlockResult(EFail);
       
   557 		}
       
   558 	}
       
   559 
       
   560 
       
   561 /** Call CFbsTypefaceStore::SetDefaultBitmapType() */
       
   562 void CT_DataFbsTypefaceStore::DoCmdSetDefaultBitmapType(const TDesC& aSection)
       
   563 	{
       
   564 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::SetDefaultBitmapType()"));
       
   565 
       
   566 	// get expected value of default bitmap type from parameters
       
   567 	TGlyphBitmapType	glyphBitmapType;
       
   568 	if (!CT_GraphicsUtil::ReadGlyphBitmapType(*this, aSection, KGlyphBitmapType(), glyphBitmapType))
       
   569 		{
       
   570 		ERR_PRINTF1(_L("No glyph_bitmap_type"));
       
   571 		SetBlockResult(EFail);
       
   572 		}
       
   573 
       
   574 	// get actual value of default bitmap type
       
   575 	iFbsTypefaceStore->SetDefaultBitmapType(glyphBitmapType);
       
   576 	}
       
   577 
       
   578 
       
   579 /** Calls SetFontNameAliasL() for the given font name and alias name */
       
   580 void CT_DataFbsTypefaceStore::DoCmdSetFontNameAlias(const TDesC& aSection)
       
   581 	{
       
   582 	INFO_PRINTF1(_L("Calls SetFontNameAliasL() for the given font name and alias name"));
       
   583 	TBool								dataOk=ETrue;
       
   584 
       
   585 	// get font name from parameters
       
   586 	TPtrC	fontName;
       
   587 	if (!GetStringFromConfig(aSection, KFontName(), fontName))
       
   588 		{
       
   589 		ERR_PRINTF2(_L("No %S"), &KFontName());
       
   590 		SetBlockResult(EFail);
       
   591 		dataOk=EFalse;
       
   592 		}
       
   593 
       
   594 	// get font name alias from parameters
       
   595 	TPtrC	fontNameAlias;
       
   596 	if (!GetStringFromConfig(aSection, KFontNameAlias(), fontNameAlias))
       
   597 		{
       
   598 		ERR_PRINTF2(_L("No %S"), &KFontNameAlias());
       
   599 		SetBlockResult(EFail);
       
   600 		dataOk=EFalse;
       
   601 		}
       
   602 
       
   603 	if ( dataOk )
       
   604 		{
       
   605 		// set font name alias
       
   606 		TRAPD(err, iFbsTypefaceStore->SetFontNameAliasL(fontNameAlias, fontName));
       
   607 
       
   608 		// check error code
       
   609 		if (err != KErrNone)
       
   610 			{
       
   611 			ERR_PRINTF2(_L("Set font name alias error: %d"), err);
       
   612 			SetError(err);
       
   613 			}
       
   614 		}
       
   615 	}
       
   616 
       
   617 
       
   618 /** Call CFbsTypefaceStore::SetDefaultLanguageForMetrics() */
       
   619 void CT_DataFbsTypefaceStore::DoCmdSetDefaultLanguageForMetrics(const TDesC& aSection)
       
   620 	{
       
   621 	INFO_PRINTF1(_L("Call CFbsTypefaceStore::SetDefaultLanguageForMetrics()"));
       
   622 
       
   623 	// get language from parameters
       
   624 	TInt	language;
       
   625 	if(!GetIntFromConfig(aSection, KLanguage(), language))
       
   626 		{
       
   627 		ERR_PRINTF2(_L("No %S"), &KLanguage());
       
   628 		SetBlockResult(EFail);
       
   629 		}
       
   630 	else
       
   631 		{
       
   632 		// call SetDefaultLanguageForMetrics for the given language
       
   633 		iFbsTypefaceStore->SetDefaultLanguageForMetrics((TLanguage) language);
       
   634 		}
       
   635 	}
       
   636 
       
   637 
       
   638 /** Call CFbsTypefaceStore::RemoveFontFileLocksL() */
       
   639 void CT_DataFbsTypefaceStore::DoCmdRemoveFontFileLocks(const TDesC& aSection)
       
   640 	{
       
   641 	// get if to call by file name flag from parameters
       
   642 	TBool	useFileName = EFalse;
       
   643 	GetBoolFromConfig(aSection, KUseFileName(), useFileName);
       
   644 
       
   645 	// get if to call by drive name flag from parameters
       
   646 	TBool	useDriveName = EFalse;
       
   647 	GetBoolFromConfig(aSection, KUseDriveName(), useDriveName);
       
   648 
       
   649 	TInt	err = KErrNone;
       
   650 
       
   651 	if (useDriveName && useFileName)
       
   652 		{
       
   653 		ERR_PRINTF1(_L("Cannot all by both file and drive name"));
       
   654 		SetBlockResult(EFail);
       
   655 		}
       
   656 	else if (useDriveName)
       
   657 		{
       
   658 		// get drive name from parameters
       
   659 		TPtrC	driveName;
       
   660 		if (!GetStringFromConfig(aSection, KDriveName(), driveName))
       
   661 			{
       
   662 			ERR_PRINTF2(_L("No %S"), &KDriveName());
       
   663 			SetBlockResult(EFail);
       
   664 			}
       
   665 
       
   666 		// get all-fonts boolean value from parameters
       
   667 		TBool	allFonts = EFalse;
       
   668 		GetBoolFromConfig(aSection, KAllFonts(), allFonts);
       
   669 
       
   670 		// call RemoveFontFileLocksL()
       
   671 		TRAP(err, iFbsTypefaceStore->RemoveFontFileLocksL(driveName, allFonts));
       
   672 		}
       
   673 	else if (useFileName)
       
   674 		{
       
   675 		// get file name from parameters
       
   676 		TPtrC	fileName;
       
   677 		if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
   678 			{
       
   679 			ERR_PRINTF2(_L("No %S"), &KFileName());
       
   680 			SetBlockResult(EFail);
       
   681 			}
       
   682 		else
       
   683 			{
       
   684 			// call RemoveFontFileLocksL()
       
   685 			TRAP(err, iFbsTypefaceStore->RemoveFontFileLocksL(fileName));
       
   686 			}
       
   687 		}
       
   688 	else
       
   689 		{
       
   690 		TRAP(err, iFbsTypefaceStore->RemoveFontFileLocksL());
       
   691 		}
       
   692 
       
   693 	// check error code
       
   694 	if (err != KErrNone)
       
   695 		{
       
   696 		ERR_PRINTF2(_L("Remove font file lock error: %d"), err);
       
   697 		SetError(err);
       
   698 		}
       
   699 	}
       
   700 
       
   701 
       
   702 /** Call CFbsTypefaceStore::SetSystemDefaultTypefaceNameL() */
       
   703 void CT_DataFbsTypefaceStore::DoCmdSetSystemDefaultTypefaceName(const TDesC& aSection)
       
   704 	{
       
   705 
       
   706 	TPtrC	name;
       
   707 	if ( GetStringFromConfig(aSection, KFontName(), name) )
       
   708 		{
       
   709 		TRAPD(err, iFbsTypefaceStore->SetSystemDefaultTypefaceNameL(name));
       
   710 		if (err != KErrNone)
       
   711 			{
       
   712 			ERR_PRINTF2(_L("SetSystemDefaultTypefaceNameL error: %d"), err);
       
   713 			SetError(err);
       
   714 			}
       
   715 		}
       
   716 	else
       
   717 		{
       
   718 		ERR_PRINTF2(_L("No %S"), &KFontName());
       
   719 		SetBlockResult(EFail);
       
   720 		}
       
   721 	}
       
   722