|
1 /* |
|
2 * Copyright (c) 2006 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: Layout metrics |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alf/alflayoutmetrics.h" |
|
21 #include "alf/alftextstylemanager.h" |
|
22 #include "alf/alftextstyle.h" |
|
23 #include "alf/alftextvisual.h" |
|
24 #include "alf/alfvisual.h" |
|
25 #include "alf/alfutil.h" |
|
26 #include "alf/alfenv.h" |
|
27 #include "alfclient.h" |
|
28 |
|
29 #include <e32debug.h> |
|
30 #include <avkon.hrh> |
|
31 #include <flogger.h> |
|
32 #include <AknFontCategory.hrh> |
|
33 |
|
34 |
|
35 _LIT(KHeader,"Comp Type|id|variety|name|Alias|type|Width|Height|Left|Right|Top|Bottom|Remarks|parent_id|parent_variety|Multi Row|Number of rows|style 1|style 2|style 3|Concatenated rows"); |
|
36 _LIT(KDelimeterChar,"|"); |
|
37 _LIT(KTypeText,"Text"); |
|
38 _LIT(KTypePane,"Pane"); |
|
39 _LIT(KVariety,"0"); |
|
40 _LIT(KFontPrimary,"qfn_primary"); |
|
41 _LIT(KFontPrimarySmall,"qfn_primary_small"); |
|
42 _LIT(KFontSecondary,"qfn_secondary"); |
|
43 _LIT(KFontTitle,"qfn_title"); |
|
44 _LIT(KFontDigital,"qfn_digital"); |
|
45 _LIT(KFontEmpty," "); |
|
46 _LIT(KFontUnknown,"unknown font"); |
|
47 _LIT(KRemarks," "); |
|
48 _LIT(KParentVariety,"0"); |
|
49 _LIT(KMultiRowYes,"true"); |
|
50 _LIT(KMultiRowNo,"-"); |
|
51 _LIT(KNumberOfRowsNone,"-"); |
|
52 _LIT(KStyle1Plain,"plain"); |
|
53 _LIT(KStyle1Bold,"bold"); |
|
54 _LIT(KStyle1Empty,"-"); |
|
55 _LIT(KStyle2Regular,"regular"); |
|
56 _LIT(KStyle2Italic,"italic"); |
|
57 _LIT(KStyle2Empty,"-"); |
|
58 _LIT(KStyle3None,"none"); |
|
59 _LIT(KStyle3Empty,"-"); |
|
60 _LIT(KStyleConcatenatedRowsDefault,"true"); |
|
61 _LIT(KStyleConcatenatedRowsEmpty,"-"); |
|
62 _LIT(KNewLine,"\n"); |
|
63 _LIT(KReportFileNameDefaultStart, "\\pqp_apps_"); |
|
64 _LIT(KReportFileNameDefaultLscEnd, "_lsc.txt"); |
|
65 _LIT(KReportFileNameDefaultPrtEnd, "_prt.txt"); |
|
66 |
|
67 |
|
68 |
|
69 const TInt KParentIdStart = 200000; |
|
70 const TInt KIdStart = 100000; |
|
71 |
|
72 |
|
73 struct TMarkedVisualEntry |
|
74 { |
|
75 public: |
|
76 ~TMarkedVisualEntry() |
|
77 { |
|
78 } |
|
79 TMarkedVisualEntry(): |
|
80 iLogicalName(NULL), |
|
81 iAlias(NULL), |
|
82 iVisual(NULL), |
|
83 iTextSize(0,0), |
|
84 iMaxLineCount(0), |
|
85 iFontId(0), |
|
86 iTextStyle(EAlfTextStyleNotAHuiStyle), |
|
87 iVisualPosition(0,0), |
|
88 iVisualSize(0,0) |
|
89 { |
|
90 } |
|
91 |
|
92 HBufC* iLogicalName; |
|
93 HBufC* iAlias; |
|
94 CAlfTextVisual* iVisual; |
|
95 TSize iTextSize; |
|
96 TInt iMaxLineCount; |
|
97 TInt iFontId; |
|
98 TAlfPreconfiguredTextStyle iTextStyle; |
|
99 TPoint iVisualPosition; |
|
100 TPoint iVisualSize; |
|
101 }; |
|
102 |
|
103 struct CAlfLayoutMetricsUtility::TMetricsPrivateData |
|
104 { |
|
105 RArray<TMarkedVisualEntry> iEntries; // Owned |
|
106 TBool iAutoMarking; |
|
107 CAlfEnv* iEnv; |
|
108 }; |
|
109 |
|
110 |
|
111 // ======== MEMBER FUNCTIONS ======== |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // Constructor |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CAlfLayoutMetricsUtility::CAlfLayoutMetricsUtility() |
|
118 { |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Destructor |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 CAlfLayoutMetricsUtility::~CAlfLayoutMetricsUtility() |
|
126 { |
|
127 if ( iMetricsData ) |
|
128 { |
|
129 TInt count = iMetricsData->iEntries.Count(); |
|
130 for(TInt i = 0; i < count; i++) |
|
131 { |
|
132 delete iMetricsData->iEntries[i].iLogicalName; |
|
133 iMetricsData->iEntries[i].iLogicalName = NULL; |
|
134 |
|
135 delete iMetricsData->iEntries[i].iAlias; |
|
136 iMetricsData->iEntries[i].iAlias = NULL; |
|
137 } |
|
138 iMetricsData->iEntries.Close(); |
|
139 } |
|
140 |
|
141 delete iMetricsData; |
|
142 iMetricsData = NULL; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // ?description |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 CAlfLayoutMetricsUtility* CAlfLayoutMetricsUtility::NewL(CAlfEnv& aEnv) |
|
150 { |
|
151 CAlfLayoutMetricsUtility* self = |
|
152 CAlfLayoutMetricsUtility::NewLC(aEnv); |
|
153 CleanupStack::Pop( self ); |
|
154 return self; |
|
155 } |
|
156 |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // ?description |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 CAlfLayoutMetricsUtility* CAlfLayoutMetricsUtility::NewLC(CAlfEnv& aEnv) |
|
163 { |
|
164 CAlfLayoutMetricsUtility* self = new( ELeave ) CAlfLayoutMetricsUtility; |
|
165 CleanupStack::PushL( self ); |
|
166 self->ConstructL(aEnv); |
|
167 return self; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // ?description |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CAlfLayoutMetricsUtility::ConstructL(CAlfEnv& aEnv) |
|
175 { |
|
176 iMetricsData = new (ELeave) TMetricsPrivateData; |
|
177 iMetricsData->iAutoMarking = EFalse; |
|
178 iMetricsData->iEnv = &aEnv; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C void CAlfLayoutMetricsUtility::MarkVisual(TDesC* aLogicalName, |
|
186 CAlfTextVisual* aVisual) |
|
187 { |
|
188 TRAP_IGNORE(MarkVisualL(aLogicalName, aVisual)) |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CAlfLayoutMetricsUtility::MarkVisualL(TDesC* aLogicalName, |
|
196 CAlfTextVisual* aVisual) |
|
197 { |
|
198 TInt count = iMetricsData->iEntries.Count(); |
|
199 for(TInt i = 0; i < count; i++) |
|
200 { |
|
201 if (aVisual == iMetricsData->iEntries[i].iVisual) |
|
202 { |
|
203 delete iMetricsData->iEntries[i].iLogicalName; |
|
204 iMetricsData->iEntries[i].iLogicalName = NULL; |
|
205 |
|
206 delete iMetricsData->iEntries[i].iAlias; |
|
207 iMetricsData->iEntries[i].iAlias = NULL; |
|
208 |
|
209 iMetricsData->iEntries.Remove(i); |
|
210 break; |
|
211 } |
|
212 } |
|
213 |
|
214 TMarkedVisualEntry entry; |
|
215 if (aLogicalName) |
|
216 { |
|
217 entry.iLogicalName = aLogicalName->AllocL(); |
|
218 } |
|
219 |
|
220 entry.iVisual = aVisual; |
|
221 iMetricsData->iEntries.Append(entry); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C void CAlfLayoutMetricsUtility::UnmarkVisual(CAlfTextVisual* aVisual) |
|
229 { |
|
230 TInt count = iMetricsData->iEntries.Count(); |
|
231 for(TInt i = 0; i < count; i++) |
|
232 { |
|
233 if (aVisual == iMetricsData->iEntries[i].iVisual) |
|
234 { |
|
235 delete iMetricsData->iEntries[i].iLogicalName; |
|
236 iMetricsData->iEntries[i].iLogicalName = NULL; |
|
237 |
|
238 delete iMetricsData->iEntries[i].iAlias; |
|
239 iMetricsData->iEntries[i].iAlias = NULL; |
|
240 |
|
241 iMetricsData->iEntries.Remove(i); |
|
242 break; |
|
243 } |
|
244 } |
|
245 |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C void CAlfLayoutMetricsUtility::MeasureVisuals() |
|
253 { |
|
254 TRAP_IGNORE(MeasureVisualsL()) |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 void CAlfLayoutMetricsUtility::MeasureVisualsL() |
|
262 { |
|
263 TInt count = iMetricsData->iEntries.Count(); |
|
264 for(TInt i = 0; i < count; i++) |
|
265 { |
|
266 CAlfTextVisual* visual = iMetricsData->iEntries[i].iVisual; |
|
267 if (visual->EffectiveOpacity() > 0.0) |
|
268 { |
|
269 iMetricsData->iEntries[i].iTextSize = |
|
270 TSize(visual->Size().IntValueNow().iX - visual->HorizontalPadding()*2, |
|
271 visual->TextExtents().iHeight); |
|
272 |
|
273 iMetricsData->iEntries[i].iMaxLineCount = visual->MaxLineCount(); |
|
274 // iMetricsData->iEntries[i].iFontId = visual->FontId(); |
|
275 // CAlfTextVisual::FontId() has been deprecated for long and returns only zero. |
|
276 iMetricsData->iEntries[i].iFontId = 0; |
|
277 iMetricsData->iEntries[i].iTextStyle = visual->Style(); |
|
278 iMetricsData->iEntries[i].iVisualPosition = visual->Pos().IntValueNow(); |
|
279 iMetricsData->iEntries[i].iVisualPosition.iX += visual->HorizontalPadding(); |
|
280 iMetricsData->iEntries[i].iVisualSize = visual->Size().IntValueNow(); |
|
281 iMetricsData->iEntries[i].iVisualSize.iX -= visual->HorizontalPadding(); |
|
282 |
|
283 delete iMetricsData->iEntries[i].iAlias; |
|
284 iMetricsData->iEntries[i].iAlias = NULL; |
|
285 iMetricsData->iEntries[i].iAlias = visual->Text().AllocL(); |
|
286 |
|
287 if (!iMetricsData->iEntries[i].iLogicalName) |
|
288 { |
|
289 iMetricsData->iEntries[i].iLogicalName = visual->Text().AllocL(); |
|
290 } |
|
291 |
|
292 // If max linecount has not been set to textvisual, |
|
293 // we kindly here calculate it. |
|
294 if (iMetricsData->iEntries[i].iMaxLineCount > 1) |
|
295 { |
|
296 if (iMetricsData->iEntries[i].iMaxLineCount == KMaxTInt && |
|
297 iMetricsData->iEntries[i].iTextSize.iHeight) |
|
298 { |
|
299 iMetricsData->iEntries[i].iMaxLineCount = |
|
300 iMetricsData->iEntries[i].iVisualSize.iY/iMetricsData->iEntries[i].iTextSize.iHeight; |
|
301 } |
|
302 } |
|
303 } |
|
304 } |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 EXPORT_C void CAlfLayoutMetricsUtility::EnableAutoMarking(TBool aEnabled) |
|
312 { |
|
313 iMetricsData->iAutoMarking = aEnabled; |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 EXPORT_C TBool CAlfLayoutMetricsUtility::AutoMarking() |
|
321 { |
|
322 return iMetricsData->iAutoMarking; |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C void CAlfLayoutMetricsUtility::WriteReport() |
|
330 { |
|
331 TBuf<512> b; |
|
332 |
|
333 b.Zero(); |
|
334 b.Append(KHeader); |
|
335 b.Append(KNewLine); |
|
336 |
|
337 PrintToFile(b); |
|
338 |
|
339 TInt count = iMetricsData->iEntries.Count(); |
|
340 for(TInt i = 0; i < count; i++) |
|
341 { |
|
342 TMarkedVisualEntry e = iMetricsData->iEntries[i]; |
|
343 |
|
344 TSize screensize = AlfUtil::ScreenSize(); |
|
345 |
|
346 const TDesC* multiRow = &KMultiRowNo; |
|
347 TBuf<12> rows; |
|
348 rows.Zero(); |
|
349 |
|
350 if (e.iMaxLineCount > 1) |
|
351 { |
|
352 multiRow = &KMultiRowYes; |
|
353 rows.AppendNum(e.iMaxLineCount); |
|
354 } |
|
355 else |
|
356 { |
|
357 rows.Append( KNumberOfRowsNone ); |
|
358 } |
|
359 |
|
360 |
|
361 TBuf<64> font; |
|
362 font.Zero(); |
|
363 |
|
364 TBuf<64> style1; |
|
365 style1.Zero(); |
|
366 |
|
367 TBuf<64> style2; |
|
368 style2.Zero(); |
|
369 |
|
370 TBuf<64> style3; |
|
371 style3.Zero(); |
|
372 |
|
373 if (e.iFontId) |
|
374 { |
|
375 // We use secret knowledge to decode font id |
|
376 const TUint encodedMask = 0x80000000; // 1 bits starting at bit 31 = 1000.0000.0000.0000.0000.0000.0000.0000 |
|
377 const TUint categoryMask = 0x0000000F; // 4 bits starting at bit 0 = 0000.0000.0000.0000.0000.0000.0000.1111 |
|
378 const TUint weightMask = 0x00000010; // 1 bits starting at bit 4 = 0000.0000.0000.0000.0000.0000.0001.0000 |
|
379 const TUint postureMask = 0x00000020; // 1 bits starting at bit 5 = 0000.0000.0000.0000.0000.0000.0010.0000 |
|
380 |
|
381 if ((e.iFontId & encodedMask) != 0) |
|
382 { |
|
383 TInt category = (e.iFontId & categoryMask); |
|
384 { |
|
385 if (category == KAknFontCategoryPrimary) |
|
386 { |
|
387 font.Append(KFontPrimary); |
|
388 } |
|
389 else if (category == KAknFontCategorySecondary) |
|
390 { |
|
391 font.Append(KFontSecondary); |
|
392 } |
|
393 else if (category == KAknFontCategoryTitle) |
|
394 { |
|
395 font.Append(KFontTitle); |
|
396 } |
|
397 else if (category == KAknFontCategoryPrimarySmall) |
|
398 { |
|
399 font.Append(KFontPrimarySmall); |
|
400 } |
|
401 else if (category == KAknFontCategoryDigital) |
|
402 { |
|
403 font.Append(KFontDigital); |
|
404 } |
|
405 else |
|
406 { |
|
407 font.Append(KFontUnknown); |
|
408 } |
|
409 } |
|
410 |
|
411 TInt weight = (e.iFontId & weightMask) >> 4; |
|
412 if (weight == EStrokeWeightBold) |
|
413 { |
|
414 style1.Append(KStyle1Bold); |
|
415 } |
|
416 else |
|
417 { |
|
418 style1.Append(KStyle1Plain); |
|
419 } |
|
420 |
|
421 TInt posture = (e.iFontId & postureMask) >> 5; |
|
422 if (posture == EPostureItalic) |
|
423 { |
|
424 style2.Append(KStyle2Italic); |
|
425 } |
|
426 else |
|
427 { |
|
428 style2.Append(KStyle2Regular); |
|
429 } |
|
430 |
|
431 style3.Append(KStyle3None); |
|
432 } |
|
433 else |
|
434 { |
|
435 font.Append(KFontUnknown); |
|
436 style1.Append(KStyle1Plain); |
|
437 style2.Append(KStyle2Regular); |
|
438 style3.Append(KStyle3None); |
|
439 } |
|
440 } |
|
441 else |
|
442 { |
|
443 TInt fontStyleId = 0; |
|
444 iMetricsData->iEnv->Client().LayoutMetricsTextStyleData(fontStyleId, e.iTextStyle); |
|
445 |
|
446 CAlfTextStyleManager* tsm = &iMetricsData->iEnv->TextStyleManager(); |
|
447 CAlfTextStyle* ts = tsm->TextStyle(e.iTextStyle); |
|
448 |
|
449 if (ts->IsBold()) |
|
450 { |
|
451 style1.Append(KStyle1Bold); |
|
452 } |
|
453 else |
|
454 { |
|
455 style1.Append(KStyle1Plain); |
|
456 } |
|
457 |
|
458 if (ts->IsItalic()) |
|
459 { |
|
460 style2.Append(KStyle2Italic); |
|
461 } |
|
462 else |
|
463 { |
|
464 style2.Append(KStyle2Regular); |
|
465 } |
|
466 |
|
467 style3.Append(KStyle3None); |
|
468 |
|
469 switch (fontStyleId) |
|
470 { |
|
471 case EAknLogicalFontPrimaryFont: |
|
472 { |
|
473 font.Append(KFontPrimary); |
|
474 break; |
|
475 } |
|
476 case EAknLogicalFontSecondaryFont: |
|
477 { |
|
478 font.Append(KFontSecondary); |
|
479 break; |
|
480 } |
|
481 case EAknLogicalFontTitleFont: |
|
482 { |
|
483 font.Append(KFontTitle); |
|
484 break; |
|
485 } |
|
486 case EAknLogicalFontPrimarySmallFont: |
|
487 { |
|
488 font.Append(KFontPrimarySmall); |
|
489 break; |
|
490 } |
|
491 case EAknLogicalFontDigitalFont: |
|
492 { |
|
493 font.Append(KFontDigital); |
|
494 break; |
|
495 } |
|
496 default: |
|
497 { |
|
498 font.Append(KFontPrimary); |
|
499 break; |
|
500 } |
|
501 } |
|
502 } |
|
503 |
|
504 b.Zero(); |
|
505 b.Append( KTypeText ); |
|
506 b.Append( KDelimeterChar ); |
|
507 b.AppendNum( i + KIdStart ); |
|
508 b.Append( KDelimeterChar ); |
|
509 b.Append( KVariety ); |
|
510 b.Append( KDelimeterChar ); |
|
511 b.Append( (_L("%S"), *e.iLogicalName)); |
|
512 b.Append( KDelimeterChar ); |
|
513 b.Append( (_L("%S"), *e.iAlias)); |
|
514 b.Append( KDelimeterChar ); |
|
515 b.Append( font ); |
|
516 b.Append( KDelimeterChar ); |
|
517 b.AppendNum( e.iTextSize.iWidth ); |
|
518 b.Append( KDelimeterChar ); |
|
519 b.AppendNum( e.iTextSize.iHeight ); |
|
520 b.Append( KDelimeterChar ); |
|
521 b.AppendNum( e.iVisualPosition.iX ); |
|
522 b.Append( KDelimeterChar ); |
|
523 b.AppendNum( screensize.iWidth - e.iVisualPosition.iX - e.iVisualSize.iX ); |
|
524 b.Append( KDelimeterChar ); |
|
525 b.AppendNum( e.iVisualPosition.iY ); |
|
526 b.Append( KDelimeterChar ); |
|
527 b.AppendNum( screensize.iHeight - e.iVisualPosition.iY - e.iVisualSize.iY ); |
|
528 b.Append( KDelimeterChar ); |
|
529 b.Append( KRemarks ); |
|
530 b.Append( KDelimeterChar ); |
|
531 if (e.iMaxLineCount > 1) |
|
532 { |
|
533 b.AppendNum( i + KParentIdStart ); |
|
534 } |
|
535 else |
|
536 { |
|
537 b.Append( KParentVariety ); |
|
538 } |
|
539 b.Append( KDelimeterChar ); |
|
540 b.AppendNum( 0 ); // Parent variety, always 0 |
|
541 b.Append( KDelimeterChar ); |
|
542 b.Append( KMultiRowNo ); // Multi row attribute is in the parent pane |
|
543 b.Append( KDelimeterChar ); |
|
544 b.Append( KNumberOfRowsNone ); // Number of rows attribute is in the parent pane |
|
545 b.Append( KDelimeterChar ); |
|
546 b.Append( style1 ); |
|
547 b.Append( KDelimeterChar ); |
|
548 b.Append( style2 ); |
|
549 b.Append( KDelimeterChar ); |
|
550 b.Append( style3 ); |
|
551 b.Append( KDelimeterChar ); |
|
552 b.Append( KStyleConcatenatedRowsDefault ); |
|
553 b.Append( KNewLine ); |
|
554 |
|
555 PrintToFile(b); |
|
556 |
|
557 // For multirow texts a parent pane is needed. |
|
558 if (e.iMaxLineCount > 1) |
|
559 { |
|
560 b.Zero(); |
|
561 b.Append( KTypePane ); |
|
562 b.Append( KDelimeterChar ); |
|
563 b.AppendNum( i + KParentIdStart ); |
|
564 b.Append( KDelimeterChar ); |
|
565 b.Append( KVariety ); |
|
566 b.Append( KDelimeterChar ); |
|
567 b.Append( (_L("%S"), *e.iLogicalName)); |
|
568 b.Append( _L("_parent_pane")); |
|
569 b.Append( KDelimeterChar ); |
|
570 b.Append( _L("Parent pane for ")); |
|
571 b.Append( (_L("%S"), *e.iLogicalName)); |
|
572 b.Append( _L(" (multirow text)")); |
|
573 b.Append( KDelimeterChar ); |
|
574 b.Append( KFontEmpty ); |
|
575 b.Append( KDelimeterChar ); |
|
576 b.AppendNum( e.iTextSize.iWidth ); |
|
577 b.Append( KDelimeterChar ); |
|
578 b.AppendNum(e.iVisualSize.iY ); |
|
579 b.Append( KDelimeterChar ); |
|
580 b.AppendNum( e.iVisualPosition.iX ); |
|
581 b.Append( KDelimeterChar ); |
|
582 b.AppendNum( screensize.iWidth - e.iVisualPosition.iX - e.iVisualSize.iX ); |
|
583 b.Append( KDelimeterChar ); |
|
584 b.AppendNum( e.iVisualPosition.iY ); |
|
585 b.Append( KDelimeterChar ); |
|
586 b.AppendNum( screensize.iHeight - e.iVisualPosition.iY - e.iVisualSize.iY ); |
|
587 b.Append( KDelimeterChar ); |
|
588 b.Append( KRemarks ); |
|
589 b.Append( KDelimeterChar ); |
|
590 b.AppendNum( 0 ); |
|
591 b.Append( KDelimeterChar ); |
|
592 b.Append( KParentVariety ); |
|
593 b.Append( KDelimeterChar ); |
|
594 b.Append( *multiRow ); |
|
595 b.Append( KDelimeterChar ); |
|
596 b.Append( rows ); |
|
597 b.Append( KDelimeterChar ); |
|
598 b.Append( KStyle1Empty ); |
|
599 b.Append( KDelimeterChar ); |
|
600 b.Append( KStyle2Empty ); |
|
601 b.Append( KDelimeterChar ); |
|
602 b.Append( KStyle3Empty ); |
|
603 b.Append( KDelimeterChar ); |
|
604 b.Append( KStyleConcatenatedRowsEmpty ); |
|
605 b.Append( KNewLine ); |
|
606 PrintToFile(b); |
|
607 } |
|
608 } |
|
609 } |
|
610 |
|
611 |
|
612 // --------------------------------------------------------------------------- |
|
613 // ?description |
|
614 // --------------------------------------------------------------------------- |
|
615 // |
|
616 void CAlfLayoutMetricsUtility::PrintToFile( TDesC16& aBuf ) |
|
617 { |
|
618 RFs fs; |
|
619 TBuf<512> filename; |
|
620 filename.Zero(); |
|
621 TSize screensize = AlfUtil::ScreenSize(); |
|
622 filename.Append( KReportFileNameDefaultStart ); |
|
623 if (screensize == TSize(240,320)) |
|
624 { |
|
625 filename.Append(_L("qvga")); |
|
626 filename.Append(KReportFileNameDefaultPrtEnd); |
|
627 } |
|
628 else if (screensize == TSize(320,240)) |
|
629 { |
|
630 filename.Append(_L("qvga")); |
|
631 filename.Append(KReportFileNameDefaultLscEnd); |
|
632 } |
|
633 else if (screensize == TSize(480,640)) |
|
634 { |
|
635 filename.Append(_L("vga")); |
|
636 filename.Append(KReportFileNameDefaultPrtEnd); |
|
637 } |
|
638 else if (screensize == TSize(640,480)) |
|
639 { |
|
640 filename.Append(_L("vga")); |
|
641 filename.Append(KReportFileNameDefaultLscEnd); |
|
642 } |
|
643 else if (screensize == TSize(360,640)) |
|
644 { |
|
645 filename.Append(_L("qhd")); |
|
646 filename.Append(KReportFileNameDefaultPrtEnd); |
|
647 } |
|
648 else if (screensize == TSize(640,360)) |
|
649 { |
|
650 filename.Append(_L("qhd")); |
|
651 filename.Append(KReportFileNameDefaultLscEnd); |
|
652 } |
|
653 else if (screensize == TSize(320,480)) |
|
654 { |
|
655 filename.Append(_L("hvga")); |
|
656 filename.Append(KReportFileNameDefaultPrtEnd); |
|
657 } |
|
658 else if (screensize == TSize(480,320)) |
|
659 { |
|
660 filename.Append(_L("hvga")); |
|
661 filename.Append(KReportFileNameDefaultLscEnd); |
|
662 } |
|
663 else |
|
664 { |
|
665 filename.AppendNum(screensize.iWidth); |
|
666 filename.Append(_L("x")); |
|
667 filename.AppendNum(screensize.iHeight); |
|
668 if (screensize.iWidth < screensize.iHeight) |
|
669 { |
|
670 filename.Append(KReportFileNameDefaultPrtEnd); |
|
671 } |
|
672 else |
|
673 { |
|
674 filename.Append(KReportFileNameDefaultLscEnd); |
|
675 } |
|
676 } |
|
677 |
|
678 |
|
679 if ( fs.Connect() == KErrNone ) |
|
680 { |
|
681 RFile file; |
|
682 |
|
683 // Open file in an exclusive mode so that only one thread |
|
684 // can acess it simultaneously |
|
685 TUint fileMode = EFileWrite | EFileShareExclusive; |
|
686 |
|
687 TInt err = file.Open( fs, filename, fileMode ); |
|
688 |
|
689 // Create a file if it doesn't exist |
|
690 if ( err == KErrNotFound ) |
|
691 { |
|
692 err = file.Create( fs, filename, fileMode ); |
|
693 } |
|
694 |
|
695 // Check if we have access to a file |
|
696 if ( err == KErrNone ) |
|
697 { |
|
698 TInt offset = 0; |
|
699 if ( file.Seek( ESeekEnd, offset ) == KErrNone ) |
|
700 { |
|
701 // Append text to the end of file |
|
702 TPtr8 ptr8( (TUint8*)aBuf.Ptr(), aBuf.Size(), aBuf.Size() ); |
|
703 file.Write( ptr8 ); |
|
704 } |
|
705 file.Close(); |
|
706 } |
|
707 |
|
708 fs.Close(); |
|
709 } |
|
710 } |
|
711 |
|
712 |
|
713 |