graphics/fntstore/src/T_DataLinkedTypefaceSpecification.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_DataLinkedTypefaceSpecification
       
    23 */
       
    24 
       
    25 #include "T_DataLinkedTypefaceSpecification.h"
       
    26 
       
    27 
       
    28 /*@{*/
       
    29 ///	Parameters
       
    30 _LIT(KFldTypefaceName,							"typefacename");
       
    31 
       
    32 ///	Commands
       
    33 _LIT(KCmdNewL,									"NewL");
       
    34 _LIT(KCmdDestructor,							"~");
       
    35 
       
    36 /// Logs
       
    37 _LIT(KLogMissingParameter,						"Missing parameter '%S'");
       
    38 _LIT(KLogError,									"Error=%d");
       
    39 /*@}*/
       
    40 
       
    41 
       
    42 /**
       
    43 * Two phase constructor
       
    44 */
       
    45 CT_DataLinkedTypefaceSpecification* CT_DataLinkedTypefaceSpecification::NewL()
       
    46 	{
       
    47 	CT_DataLinkedTypefaceSpecification* ret = new (ELeave) CT_DataLinkedTypefaceSpecification();
       
    48 	CleanupStack::PushL(ret);
       
    49 	ret->ConstructL();
       
    50 	CleanupStack::Pop(ret);
       
    51 	return ret;
       
    52 	}
       
    53 /**
       
    54 * Protected second phase construction
       
    55 */
       
    56 void CT_DataLinkedTypefaceSpecification::ConstructL()
       
    57 	{
       
    58 	}
       
    59 
       
    60 /**
       
    61 * Protected constructor. First phase construction
       
    62 */
       
    63 CT_DataLinkedTypefaceSpecification::CT_DataLinkedTypefaceSpecification()
       
    64 :	CDataWrapperBase()
       
    65 ,	iSpec(NULL)
       
    66 	{
       
    67 	}
       
    68 
       
    69 /**
       
    70 * Destructor.
       
    71 */
       
    72 CT_DataLinkedTypefaceSpecification::~CT_DataLinkedTypefaceSpecification()
       
    73 	{
       
    74 	DestroyData();
       
    75 	}
       
    76 
       
    77 
       
    78 /**
       
    79 * cleanup implementation.
       
    80 */
       
    81 void CT_DataLinkedTypefaceSpecification::DestroyData()
       
    82 	{
       
    83 	delete iSpec;
       
    84 	iSpec = NULL;
       
    85 	}
       
    86 
       
    87 TAny* CT_DataLinkedTypefaceSpecification::GetObject()
       
    88 	{
       
    89 	return iSpec;
       
    90 	}
       
    91 
       
    92 void CT_DataLinkedTypefaceSpecification::SetObjectL(TAny* aObject)
       
    93 	{
       
    94 	DestroyData();
       
    95 	iSpec	= static_cast<CLinkedTypefaceSpecification*> (aObject);
       
    96 	}
       
    97 		
       
    98 void CT_DataLinkedTypefaceSpecification::DisownObjectL() 
       
    99 	{
       
   100 	iSpec = NULL;
       
   101 	}
       
   102 
       
   103 /**
       
   104 * Process a command read from the ini file
       
   105 *
       
   106 * @param aDataWrapper	test step requiring command to be processed
       
   107 * @param aCommand	the command to process
       
   108 * @param aSection		the entry in the ini file requiring the command to be processed
       
   109 *
       
   110 * @return ETrue if the command is processed
       
   111 */
       
   112 TBool CT_DataLinkedTypefaceSpecification::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
   113 	{
       
   114 	TBool retVal = ETrue;
       
   115 
       
   116 	if (aCommand == KCmdNewL)
       
   117 		{
       
   118 		DoCmdNewL(aSection);
       
   119 		}
       
   120 	else if (aCommand == KCmdDestructor)
       
   121 		{
       
   122 		DoCmdDestructor();
       
   123 		}
       
   124 	else
       
   125 		{
       
   126 		retVal=EFalse;
       
   127 		}
       
   128 
       
   129 	return retVal;
       
   130 	}
       
   131 
       
   132 
       
   133 ////////////////// COMMANDS IMPLEMENTATION  ////////////////////////
       
   134 
       
   135 /** Creates an instance of CT_DataLinkedTypefaceSpecification class */
       
   136 void CT_DataLinkedTypefaceSpecification::DoCmdNewL(const TDesC& aSection)
       
   137 	{
       
   138 	// cleanup if any
       
   139 	DestroyData();
       
   140 
       
   141 	// call new operator
       
   142 	TPtrC name;
       
   143 	if (!GetStringFromConfig(aSection, KFldTypefaceName, name))
       
   144 		{
       
   145 		ERR_PRINTF2(KLogMissingParameter, &KFldTypefaceName);
       
   146 		SetBlockResult(EFail);
       
   147 		}
       
   148 	else
       
   149 		{
       
   150 		INFO_PRINTF1(_L("execute CLinkedTypefaceSpecification::NewLC"));
       
   151 		TRAPD(err, iSpec = CLinkedTypefaceSpecification::NewLC(name); CleanupStack::Pop(iSpec));
       
   152 		if (err != KErrNone)
       
   153 			{
       
   154 			ERR_PRINTF2(KLogError, err);
       
   155 			SetError(err);
       
   156 			}
       
   157 		}
       
   158 	}
       
   159 
       
   160 void CT_DataLinkedTypefaceSpecification::DoCmdDestructor()
       
   161 	{
       
   162 	// cleanup if any
       
   163 	DestroyData();
       
   164 	}