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