graphicsapitest/graphicssvs/bitgdi/src/T_DataFbsBitGcFont.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 "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 @test
       
    20 @internalComponent
       
    21 
       
    22 This contains CT_DataFbsBitGcFont
       
    23 */
       
    24 
       
    25 #include "T_DataFbsBitGcFont.h"
       
    26 
       
    27 /*@{*/
       
    28 ///	Parameters
       
    29 _LIT(KFldHandle,						"handle");
       
    30 _LIT(KFontDataObjectName,				"font_data_object_name");
       
    31 
       
    32 ///	Commands
       
    33 _LIT(KCmdNewL,							"NewL");
       
    34 _LIT(KCmdDestructor,					"~");
       
    35 _LIT(KCmdAddress,						"Address");
       
    36 _LIT(KCmdDuplicate,						"Duplicate");
       
    37 _LIT(KCmdReset, 						"Reset");
       
    38 
       
    39 
       
    40 /// Logs
       
    41 _LIT(KLogMissingParameter,				"Missing parameter '%S'");
       
    42 _LIT(KLogErrNum,						"Execute failed with error = %d!");	
       
    43 /*@}*/
       
    44 
       
    45 
       
    46 /**
       
    47 * Constructor
       
    48 */
       
    49 CT_DataFbsBitGcFont* CT_DataFbsBitGcFont::NewL()
       
    50 	{
       
    51 	CT_DataFbsBitGcFont* ret = new (ELeave) CT_DataFbsBitGcFont();
       
    52 	CleanupStack::PushL(ret);
       
    53 	ret->ConstructL();
       
    54 	CleanupStack::Pop(ret);
       
    55 	return ret;
       
    56 	}
       
    57 
       
    58 /**
       
    59 * Protected constructor. First phase construction
       
    60 */
       
    61 CT_DataFbsBitGcFont::CT_DataFbsBitGcFont()
       
    62 :	CT_DataFbsFont()
       
    63 ,	iFbsBitGcFont(NULL)
       
    64 	{
       
    65 	}
       
    66 
       
    67 /**
       
    68 * Protected second phase construction
       
    69 */
       
    70 void CT_DataFbsBitGcFont::ConstructL()
       
    71 	{
       
    72 	}
       
    73 
       
    74 /**
       
    75 * Destructor.
       
    76 */
       
    77 CT_DataFbsBitGcFont::~CT_DataFbsBitGcFont()
       
    78 	{
       
    79 	DisownObjectL();
       
    80 	}
       
    81 
       
    82 
       
    83 CFont*	CT_DataFbsBitGcFont::GetFont() const
       
    84 	{
       
    85 	return iFbsBitGcFont;
       
    86 	}
       
    87 
       
    88 CFbsFont* CT_DataFbsBitGcFont::GetFbsFont() const
       
    89 	{
       
    90 	return iFbsBitGcFont;
       
    91 	}
       
    92 
       
    93 /**
       
    94 * Return a pointer to the object that the data wraps
       
    95 *
       
    96 * @return pointer to the object that the data wraps
       
    97 */
       
    98 TAny* CT_DataFbsBitGcFont::GetObject()
       
    99 	{
       
   100 	return iFbsBitGcFont;
       
   101 	}
       
   102 
       
   103 void CT_DataFbsBitGcFont::SetObjectL(TAny* aObject)
       
   104 	{
       
   105 	iFbsBitGcFont = static_cast<CFbsBitGcFont*> (aObject);
       
   106 	}
       
   107 
       
   108 void CT_DataFbsBitGcFont::DisownObjectL() 
       
   109 	{
       
   110 	iFbsBitGcFont = NULL;
       
   111 	}
       
   112 
       
   113 
       
   114 /**
       
   115 * Process a command read from the ini file
       
   116 *
       
   117 * @param aDataWrapper	test step requiring command to be processed
       
   118 * @param aCommand		the command to process
       
   119 * @param aSection		the entry in the ini file requiring the command to be processed
       
   120 *
       
   121 * @return ETrue if the command is processed
       
   122 */
       
   123 TBool CT_DataFbsBitGcFont::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   124 	{
       
   125 	/* Another work package will complete the implement of this */
       
   126 	TBool	retVal = ETrue;
       
   127 
       
   128 	if ( aCommand == KCmdNewL )
       
   129 		{
       
   130 		DoCmdNewL();
       
   131 		}
       
   132 	else if (aCommand == KCmdDestructor)
       
   133 		{
       
   134 		DoCmdDestructor();
       
   135 		}
       
   136 	else if (aCommand == KCmdAddress)
       
   137 		{
       
   138 		DoCmdAddress();
       
   139 		}
       
   140 	else if (aCommand == KCmdDuplicate)
       
   141 		{
       
   142 		DoCmdDuplicate(aSection);
       
   143 		}
       
   144 	else if (aCommand == KCmdReset)
       
   145 		{
       
   146 		DoCmdReset();
       
   147 		}
       
   148 	else
       
   149 		{
       
   150 		retVal = CT_DataFbsFont::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   151 		}
       
   152 	return retVal;
       
   153 	}
       
   154 
       
   155 
       
   156 void CT_DataFbsBitGcFont::DoCmdNewL()
       
   157 	{
       
   158 	TInt err = KErrNone;
       
   159 	INFO_PRINTF1(_L("Create CFbsBitGcFont Object by CFbsBitGcFont() constructor function."));
       
   160 	TRAP(err, iFbsBitGcFont = new (ELeave) CFbsBitGcFont());
       
   161 	if ( err!=KErrNone )
       
   162 		{
       
   163 		ERR_PRINTF2(KLogErrNum, err);
       
   164 		SetError(err);
       
   165 		}
       
   166 	}
       
   167 
       
   168 void CT_DataFbsBitGcFont::DoCmdDestructor()
       
   169 	{
       
   170 	DisownObjectL();
       
   171 	}
       
   172 
       
   173 void CT_DataFbsBitGcFont::DoCmdAddress()
       
   174 	{
       
   175 	CBitmapFont* BitmapFontPtr = NULL;
       
   176 	INFO_PRINTF1(_L("Execute CFbsBitGcFont::Address() function."));
       
   177 	
       
   178 	BitmapFontPtr = iFbsBitGcFont->Address();
       
   179 	if (NULL == BitmapFontPtr)
       
   180 		{
       
   181 		INFO_PRINTF1(_L("The CBitmapFont* returned is NULL."));
       
   182 		}
       
   183 	}
       
   184 
       
   185 void CT_DataFbsBitGcFont::DoCmdDuplicate(const TDesC& aSection)
       
   186 	{
       
   187 	TInt handle = 0;
       
   188 	INFO_PRINTF1(_L("Execute CFbsBitGcFont::Duplicate(TInt aHandle) function."));
       
   189 	
       
   190 	if(GetIntFromConfig(aSection,KFldHandle,handle))
       
   191 		{
       
   192 		INFO_PRINTF2(_L("Execute Duplicate(TInt aHandle) using the specified handle = %d"), handle);
       
   193 		}
       
   194 	else
       
   195 		{
       
   196 		TPtrC fontDataObjectName;
       
   197 		if (!GetStringFromConfig(aSection, KFontDataObjectName(), fontDataObjectName))
       
   198 			{
       
   199 			ERR_PRINTF2(KLogMissingParameter, &KFontDataObjectName);
       
   200 			SetBlockResult(EFail);
       
   201 			return;
       
   202 			}
       
   203 		else
       
   204 			{
       
   205 			CT_DataFbsBitGcFont* fontDataObject = NULL;
       
   206 			fontDataObject = static_cast<CT_DataFbsBitGcFont*>(GetDataWrapperL(fontDataObjectName));
       
   207 			if (NULL == fontDataObject)
       
   208 				{
       
   209 				ERR_PRINTF1(_L("Bad Object!"));
       
   210 				SetBlockResult(EFail);
       
   211 				return;
       
   212 				}
       
   213 			else
       
   214 				{
       
   215 				handle = ((CFbsBitGcFont*)fontDataObject->GetObject())->Handle();
       
   216 				INFO_PRINTF2(_L("Execute Duplicate(TInt aHandle) using CFbsBitGcFont Object's handle = %d"), handle);
       
   217 				}
       
   218 			}
       
   219 		}
       
   220 	
       
   221 	TInt err = iFbsBitGcFont->Duplicate(handle);
       
   222 	if (KErrNone != err)
       
   223 		{
       
   224 		ERR_PRINTF2(KLogErrNum, err);
       
   225 		SetError(err);
       
   226 		}
       
   227 	}
       
   228 
       
   229 void CT_DataFbsBitGcFont::DoCmdReset()
       
   230 	{
       
   231 	INFO_PRINTF1(_L("Execute CFbsBitGcFont::Reset() function."));
       
   232 	iFbsBitGcFont->Reset();
       
   233 	}