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_DataDrawTextParam |
|
23 */ |
|
24 |
|
25 // User includes |
|
26 #include "T_DataDrawTextParam.h" |
|
27 #include "T_GraphicsUtil.h" |
|
28 |
|
29 /*@{*/ |
|
30 /// Commands |
|
31 _LIT(KCmd_new, "new"); |
|
32 _LIT(KCmd_destructor, "~"); |
|
33 _LIT(KCmd_iDirection, "iDirection"); |
|
34 _LIT(KCmd_iCharJustNum, "iCharJustNum"); |
|
35 _LIT(KCmd_iCharJustExcess, "iCharJustExcess"); |
|
36 _LIT(KCmd_iWordJustNum, "iWordJustNum"); |
|
37 _LIT(KCmd_iWordJustExcess, "iWordJustExcess"); |
|
38 |
|
39 /// Parameters |
|
40 _LIT(KFldValue, "value"); |
|
41 |
|
42 /// Logging |
|
43 _LIT(KLogError, "Error=%d"); |
|
44 /*@}*/ |
|
45 |
|
46 /** |
|
47 * Constructor. First phase construction |
|
48 */ |
|
49 CT_DataDrawTextParam::CT_DataDrawTextParam() |
|
50 : CDataWrapperBase() |
|
51 , iDrawTextParam(NULL) |
|
52 { |
|
53 } |
|
54 |
|
55 /** |
|
56 * Constructor. First phase construction |
|
57 */ |
|
58 CT_DataDrawTextParam::~CT_DataDrawTextParam() |
|
59 { |
|
60 DestroyData(); |
|
61 } |
|
62 |
|
63 void CT_DataDrawTextParam::DestroyData() |
|
64 { |
|
65 delete iDrawTextParam; |
|
66 iDrawTextParam=NULL; |
|
67 } |
|
68 |
|
69 TAny* CT_DataDrawTextParam::GetObject() |
|
70 { |
|
71 return iDrawTextParam; |
|
72 } |
|
73 |
|
74 void CT_DataDrawTextParam::SetObjectL(TAny* aAny) |
|
75 { |
|
76 DestroyData(); |
|
77 iDrawTextParam=static_cast<CGraphicsContext::TDrawTextParam*>(aAny); |
|
78 } |
|
79 |
|
80 void CT_DataDrawTextParam::DisownObjectL() |
|
81 { |
|
82 iDrawTextParam=NULL; |
|
83 } |
|
84 |
|
85 CGraphicsContext::TDrawTextParam* CT_DataDrawTextParam::GetDrawTextParam() const |
|
86 { |
|
87 return iDrawTextParam; |
|
88 } |
|
89 |
|
90 /** |
|
91 * Process a command read from the ini file |
|
92 * |
|
93 * @param aDataWrapper test step requiring command to be processed |
|
94 * @param aCommand the command to process |
|
95 * @param aSection the entry in the ini file requiring the command to be processed |
|
96 * |
|
97 * @return ETrue if the command is processed |
|
98 */ |
|
99 TBool CT_DataDrawTextParam::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
100 { |
|
101 TBool ret=ETrue; |
|
102 if ( aCommand==KCmd_new ) |
|
103 { |
|
104 DoCmd_new(); |
|
105 } |
|
106 else if ( aCommand==KCmd_destructor ) |
|
107 { |
|
108 DoCmd_destructor(); |
|
109 } |
|
110 else if ( aCommand==KCmd_iDirection ) |
|
111 { |
|
112 DoCmd_iDirection(aSection); |
|
113 } |
|
114 else if ( aCommand==KCmd_iCharJustNum ) |
|
115 { |
|
116 DoCmd_iCharJustNum(aSection); |
|
117 } |
|
118 else if ( aCommand==KCmd_iCharJustExcess ) |
|
119 { |
|
120 DoCmd_iCharJustExcess(aSection); |
|
121 } |
|
122 else if ( aCommand==KCmd_iWordJustNum ) |
|
123 { |
|
124 DoCmd_iWordJustNum(aSection); |
|
125 } |
|
126 else if ( aCommand==KCmd_iWordJustExcess ) |
|
127 { |
|
128 DoCmd_iWordJustExcess(aSection); |
|
129 } |
|
130 else |
|
131 { |
|
132 ret=EFalse; |
|
133 } |
|
134 |
|
135 return ret; |
|
136 } |
|
137 |
|
138 void CT_DataDrawTextParam::DoCmd_new() |
|
139 { |
|
140 DestroyData(); |
|
141 TRAPD(err, iDrawTextParam = new (ELeave) CGraphicsContext::TDrawTextParam()); |
|
142 if ( err!=KErrNone ) |
|
143 { |
|
144 ERR_PRINTF2(KLogError, err); |
|
145 SetError(err); |
|
146 } |
|
147 } |
|
148 |
|
149 void CT_DataDrawTextParam::DoCmd_destructor() |
|
150 { |
|
151 DestroyData(); |
|
152 } |
|
153 |
|
154 void CT_DataDrawTextParam::DoCmd_iDirection(const TDesC& aSection) |
|
155 { |
|
156 CGraphicsContext::TDrawTextParam* textParam=GetDrawTextParam(); |
|
157 TPtrC deviceName; |
|
158 if ( !CT_GraphicsUtil::ReadTextDirection(*this, aSection, KFldValue(), textParam->iDirection) ) |
|
159 { |
|
160 INFO_PRINTF2(_L("iDirection=%d"), textParam->iDirection); |
|
161 } |
|
162 } |
|
163 |
|
164 void CT_DataDrawTextParam::DoCmd_iCharJustNum(const TDesC& aSection) |
|
165 { |
|
166 CGraphicsContext::TDrawTextParam* textParam=GetDrawTextParam(); |
|
167 TPtrC deviceName; |
|
168 if ( !GetIntFromConfig(aSection, KFldValue(), textParam->iCharJustNum) ) |
|
169 { |
|
170 INFO_PRINTF2(_L("iCharJustNum=%d"), textParam->iCharJustNum); |
|
171 } |
|
172 } |
|
173 |
|
174 void CT_DataDrawTextParam::DoCmd_iCharJustExcess(const TDesC& aSection) |
|
175 { |
|
176 CGraphicsContext::TDrawTextParam* textParam=GetDrawTextParam(); |
|
177 TPtrC deviceName; |
|
178 if ( !GetIntFromConfig(aSection, KFldValue(), textParam->iCharJustExcess) ) |
|
179 { |
|
180 INFO_PRINTF2(_L("iCharJustExcess=%d"), textParam->iCharJustExcess); |
|
181 } |
|
182 } |
|
183 |
|
184 void CT_DataDrawTextParam::DoCmd_iWordJustNum(const TDesC& aSection) |
|
185 { |
|
186 CGraphicsContext::TDrawTextParam* textParam=GetDrawTextParam(); |
|
187 TPtrC deviceName; |
|
188 if ( !GetIntFromConfig(aSection, KFldValue(), textParam->iWordJustNum) ) |
|
189 { |
|
190 INFO_PRINTF2(_L("iWordJustNum=%d"), textParam->iWordJustNum); |
|
191 } |
|
192 } |
|
193 |
|
194 void CT_DataDrawTextParam::DoCmd_iWordJustExcess(const TDesC& aSection) |
|
195 { |
|
196 CGraphicsContext::TDrawTextParam* textParam=GetDrawTextParam(); |
|
197 TPtrC deviceName; |
|
198 if ( !GetIntFromConfig(aSection, KFldValue(), textParam->iWordJustExcess) ) |
|
199 { |
|
200 INFO_PRINTF2(_L("iWordJustExcess=%d"), textParam->iWordJustExcess); |
|
201 } |
|
202 } |
|